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

when I want to create a tar archive in a relative path, I can do this:

tar cf archiveName.tar -C relative/path  someDirectory

but when I want to update the archive, this

tar uf archiveName.tar -C relative/path someDirectory 

gives me the following errors:

tar: someDirectory/someFile: Cannot stat: No such file or directory
... (same error for all files and dirs in someDirectory)
tar: Exiting with faliure...

Am I missing something?

share|improve this question
Are you running both of these configs in the same directory ? – Antoine Benkemoun Aug 31 '11 at 12:29
Yes, I'm executing them in the same dir. Also, there should be no difference in where I put the actual archiveName.tar (it can be anywhere). I have just tried it again, to be sure: added some files touch someDirectory/{1,2,3} and tried tar uf archiveName... and it broke again. – tmaric Aug 31 '11 at 12:37

Although the man page of GNU tar doesn't mentioned, I wonder that -C option only works with c (create) or r (replace) operations.

Unix man page wrote:

-C directory file
Performs a chdir (see cd(1)) operation on directory and performs the c (create) or r (replace) operation on file . Use short relative path names for file . If file is `.', archive all files in directory. This option enables archiving files from multiple directories not related by a close common parent.

So, you can use r (replace) option instead:

tar rf archiveName.tar -C relative/path someDirectory 
share|improve this answer
This works, but it executes over all files, regardless of their modification time. The goal is to update an archive in some directory (from outside of this dir) so that the full PATH is not given to the archive (using the -C) command. If I do "tar rf", it adds both the old files and the new ones again. I want to use the update in order to skip adding unchanged (old) files to the archive. It seems that "-C" doesn't work with "u" at all... – tmaric Sep 1 '11 at 6:14

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.