Re: tar files

Dennis Clark ((no email))
Thu, 8 Jun 1995 11:50:47 +1000 (EST)

In previous mail, Robert Sequeira - ENS Sys/DB Admin wrote:
>
> | On Wed, 7 Jun 1995, gland slave wrote:
> |
> | > On Wed, 7 Jun 1995, Matt Estela wrote:
> | >
> | > > How do I extract a file compressed using <filename>tar.Z ? I've tried
> | > > typing 'tar xv ./<filename>tar.Z', but it tells me there is a directory
> | > > checksum error. Any ideas?
> | >
> | > To uncompress use: gunzip <filename>.tar.Z
> | and untar with: tar xvf <filename>.tar
> |
> Stephen G.
>
> The file was orginally compressed with the standard UNIX /usr/bin/compress.
> This is why it has the .Z extension.
>
> Uncompress it first by using uncompress <filename>
> and then tar xf <filename> (This will expand the archive created by tar).

Such amateurs :)

1) gzip is compatible with UNIX compress, ie. it can decompress
.Z files, so 'gunzip <filename>.tar.Z' works as Stephen says.

2) Creating the intermediate uncompressed file is a waste of disk
space. It is much better to uncompress to a pipe and have 'tar'
extract files from it.

For <filename>.tar.Z:

zcat <filename>.tar.Z | tar xvf -

For <filename>.tar.gz:

gzip -cd <filename>.tar.gz | tar xvf -

As stated above, the 'gzip' command can process .tar.Z files
as well as .tar.gz files.

Many minor variations are possible to the command line are
possible ('uncompress -c' instead of 'zcat', 'gunzip -c' instead
of 'gzip -cd', leave the 'v' option out of tar, etc.) but they
all have the same general effect.

Hope that helps,
DB

PS. Using GNU tar to decompress and extract without explicitly using a
pipe is left as an exercise for the reader :)

--
Dennis Clark                             President, Programmers' Society
dbugger@nospam.ftoomsh.socs.uts.edu.au         University of Technology, Sydney
                "Clear code is a product of clear thought."