Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
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

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

share|improve this answer

Your Answer


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.