Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 stackoverflow.com Sep 2 '10 at 12:52

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

2 Answers 2

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

Your Answer

 
discard

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