Go to the first, previous, next, last section, table of contents.


Creating and Reading Compressed Archives

@UNREVISED

-z
--gzip
--ungzip
Filter the archive through gzip.

@FIXME{ach; these two bits orig from "compare" (?). where to put?} Some format parameters must be taken into consideration when modifying an archive: @FIXME{???}. Compressed archives cannot be modified.

You can use `--gzip' and `--gunzip' on physical devices (tape drives, etc.) and remote files as well as on normal files; data to or from such devices or remote files is reblocked by another copy of the tar program to enforce the specified (or default) record size. The default compression parameters are used; if you need to override them, avoid the --gzip (--gunzip, --ungzip, -z) option and run gzip explicitly. (Or set the `GZIP' environment variable.)

The --gzip (--gunzip, --ungzip, -z) option does not work with the --multi-volume (-M) option, or with the --update (-u), --append (-r), --concatenate (--catenate, -A), or --delete operations.

It is not exact to say that GNU tar is to work in concert with gzip in a way similar to zip, say. Surely, it is possible that tar and gzip be done with a single call, like in:

$ tar cfz archive.tar.gz subdir

to save all of `subdir' into a gzip'ed archive. Later you can do:

$ tar xfz archive.tar.gz

to explode and unpack.

The difference is that the whole archive is compressed. With zip, archive members are archived individually. tar's method yields better compression. On the other hand, one can view the contents of a zip archive without having to decompress it. As for the tar and gzip tandem, you need to decompress the archive to see its contents. However, this may be done without needing disk space, by using pipes internally:

$ tar tfz archive.tar.gz

About corrupted compressed archives: gzip'ed files have no redundancy, for maximum compression. The adaptive nature of the compression scheme means that the compression tables are implicitly spread all over the archive. If you lose a few blocks, the dynamic construction of the compression tables becomes unsychronized, and there is little chance that you could recover later in the archive.

There are pending suggestions for having a per-volume or per-file compression in GNU tar. This would allow for viewing the contents without decompression, and for resynchronizing decompression at every volume or file, in case of corrupted archives. Doing so, we might loose some compressibility. But this would have make recovering easier. So, there are pros and cons. We'll see!

-Z
--compress
--uncompress
Filter the archive through compress. Otherwise like --gzip (--gunzip, --ungzip, -z).
--use-compress-program=prog
Filter through prog (must accept `-d').

--compress (--uncompress, -Z) stores an archive in compressed format. This option is useful in saving time over networks and space in pipes, and when storage space is at a premium. --compress (--uncompress, -Z) causes tar to compress when writing the archive, or to uncompress when reading the archive.

To perform compression and uncompression on the archive, tar runs the compress utility. tar uses the default compression parameters; if you need to override them, avoid the --compress (--uncompress, -Z) option and run the compress utility explicitly. It is useful to be able to call the compress utility from within tar because the compress utility by itself cannot access remote tape drives.

The --compress (--uncompress, -Z) option will not work in conjunction with the --multi-volume (-M) option or the --append (-r), --update (-u), --append (-r) and --delete operations. See section The Five Advanced tar Operations, for more information on these operations.

If there is no compress utility available, tar will report an error. Please note that the compress program may be covered by a patent, and therefore we recommend you stop using it.

--compress
--uncompress
-z
-Z
When this option is specified, tar will compress (when writing an archive), or uncompress (when reading an archive). Used in conjunction with the --create (-c), --extract (--get, -x), --list (-t) and --compare (--diff, -d) operations.

You can have archives be compressed by using the --gzip (--gunzip, --ungzip, -z) option. This will arrange for tar to use the gzip program to be used to compress or uncompress the archive wren writing or reading it.

To use the older, obsolete, compress program, use the --compress (--uncompress, -Z) option. The GNU Project recommends you not use compress, because there is a patent covering the algorithm it uses. You could be sued for patent infringment merely by running compress.

I have one question, or maybe it's a suggestion if there isn't a way to do it now. I would like to use --gzip (--gunzip, --ungzip, -z), but I'd also like the output to be fed through a program like GNU ecc (actually, right now that's `exactly' what I'd like to use :-)), basically adding ECC protection on top of compression. It seems as if this should be quite easy to do, but I can't work out exactly how to go about it. Of course, I can pipe the standard output of tar through ecc, but then I lose (though I haven't started using it yet, I confess) the ability to have tar use rmt for it's I/O (I think).

I think the most straightforward thing would be to let me specify a general set of filters outboard of compression (preferably ordered, so the order can be automatically reversed on input operations, and with the options they require specifiable), but beggars shouldn't be choosers and anything you decide on would be fine with me.

By the way, I like ecc but if (as the comments say) it can't deal with loss of block sync, I'm tempted to throw some time at adding that capability. Supposing I were to actually do such a thing and get it (apparantly) working, do you accept contributed changes to utilities like that? (Leigh Clayton `loc@soliton.com', May 1995).

Isn't that exactly the role of the --use-compress-prog=program option? I never tried it myself, but I suspect you may want to write a prog script or program able to filter stdin to stdout to way you want. It should recognize the `-d' option, for when extraction is needed rather than creation.

It has been reported that if one writes compressed data (through the --gzip (--gunzip, --ungzip, -z) or --compress (--uncompress, -Z) options) to a DLT and tries to use the DLT compression mode, the data will actually get bigger and one will end up with less space on the tape.


Go to the first, previous, next, last section, table of contents.