Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I was looking for an answer, I thought I found it, but it doesn't work correctly :-S

Question: I want to pack: /foo/bar/dir/* but when I unpack the tar I would like to have /dir/*

So i thought:
1) tar -cvf file.tar /foo/bar/dir -C /dir
or
2) tar -cvf file.tar /foo/bar/dir -C /foo/bar

But when I open the TARs they both have the first dir: foo, then bar etc...

share|improve this question
    
This is off-topic here. –  Hauke Laging Feb 24 '13 at 17:37
    
@HaukeLaging: Why would this not be related to system administration ? –  Iain Feb 24 '13 at 17:43
    
@lain I didn't mean that tar is not related to system administration. I meant that this is a page for server professionals. Ever seen a *nix admin who doesn't know how to use tar? I have experienced more "difficult" questions which I have answered being moved to another site. By my impression of the behaviour here this is a legitimate question but on unix or superuser. –  Hauke Laging Feb 24 '13 at 17:50
add comment

2 Answers

up vote 1 down vote accepted

It is the order of the options:

tar -cvf file.tar -C /foo/bar dir
share|improve this answer
add comment

$ cd /foo/bar
$ tar -cvf /other/dir/path/file.tar dir

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.