Using tar with compress or gzip

1) To tar files up into a tarball:

tar cvfp - file1 file2 file3 > tarfile.tar

And to untar:

tar xvfp tarfile.tar

2) Now, same thing but with compress added in:

tar cvfp - file1 file2 file3 | compress > tarfile.tar.Z
zcat tarfile.tar.Z | tar xvfp -

3) And, the same thing using gzip rather than compress:

tar cvfp - file1 file2 file3 | gzip > tarfile.tar.gz
gunzip -c tarfile.tar.gz | tar xvfp -

(Or, if you prefer, “gzip -cd” is the same as “gunzip -c”)

Gzip compresses down in size slightly better than compress, but tends to take slightly longer to do so.

March 5, 2009

Leave a Reply

Your email address will not be published. Required fields are marked *