Using tar together with gzip

Posted by – September 22, 2011

How can I extract a tar.gz or .tgz file?
Files with extension tar.gz or .tgz are tar files compressed with gzip. On Unix extract them with:

gunzip < file.tar.gz | tar xvf –
gunzip < file.tgz    | tar xvf –
Can gzip compress several files into a single archive?
Not directly. You can first create a tar file then compress it:

tar cvf –  filenames | gzip > file.tar.gz

Leave a Reply