How do I unpack a compressed tar fileWhen downloading files from FTP archives, you will find that they are normally of the form filename.tar.Z or filename.tar.gz These files have been archived then compressed or zipped.
( files ending in *.tar.Z or *.tar.gz )?
Uncompressing a .Z file
Files ending in .Z have been compressed using the compress command. Compressed files can be restored to their original form using the uncompress command. Type:uncompress filename.tar.Z
This replaces filename.tar.Z with filename.tar
Unzipping a .gz fileFiles ending in .gz have been compressed using the gzip command. Zipped files can be restored to their original form using the gunzip command. Type:gunzip filename.tar.gz
This replaces filename.tar.gz with filename.tar
Extracting tar filesThe tar command is used for packing several files or even a whole directory into a single tarfile.
To unpack a tar file, type:tar xvf filename.tar
Note: Always move to an empty directory before unpacking a tarfile.
When you unpack a tarfile its contents are written to the current directory. Any file or directory with the same name as the contents of the tarfile will be overwritten!
A quick method
Alternatively, you can unpack a compressed/zipped tarfile using the zcat or gzcat command. (gzcat is a local alias for the GNU zcat command). This leaves the compressed .Z or .gz tarfile intact. For example:zcat filename.tar.Z | tar xvf - or gzcat filename.tar.gz | tar xvf -The zcat command recreates the uncompressed tarfile, which is then piped into the tar command to extract the files.
M.Stonebank@ee.surrey.ac.uk 10th November 1994