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

I am using the tar command for compression.

link|improve this question
feedback

migrated from stackoverflow.com Sep 2 '10 at 12:52

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

2 Answers

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

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

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown