Super User is a question and answer site for computer enthusiasts and power users. 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

Is there a way to add files/folders to a tar file?

I am using the tar command for compression.

share|improve this question

migrated from Sep 2 '10 at 12:52

This question came from our site for professional and enthusiast programmers.

tar doesn't compress anything, but if you want to append to an existing archive, you want the -r flag.

share|improve this answer
i want to add folder and it wont work – nis Aug 31 '10 at 16:25
@nis, I just did a test and it worked fine. What command line are you using? – Carl Norum Aug 31 '10 at 16:28
i am using linux and the commands are: tar -cfz foo.tar.gz nis1/ tar -rfz foo.tar.gz nis/ – nis Aug 31 '10 at 16:31
@nis, You can't use -r on a compressed archive. Try without the -z options. – Carl Norum Aug 31 '10 at 16:38

You can't modify a compressed tarfile. You can append (-r) or update (-u) an uncompressed archive.

share|improve this answer

You must log in to answer this question.