Compression Programs

The compress program



The gzip Program

There are other compression programs available for Unix. The commonest is gzip. It is public-domain software.

Here are some examples of its usage:

gzip bigfile.txt creates a compressed file named bigfile.txt.gz.
gunzip bigfile.txt.gz recovers the original file.
gunzip < bigfile.txt.gz | more allows you to browse the file without
destroying the compressed file.
Gzip usually produces better compression than compress, and it executes significantly faster.

Using compress or gzip with tar

Compress and gzip are often used to reduce the sizes of tar archive files before they are shipped over the internet.

A compressed tar archive can be created in a single Unix command pipeline as in the following example:

	  tar cvf - README.txt MyProject | compress > MyProject.tar.Z
The hyphen indicates that the output from the tar command is to go to standard output, not into a file.

After the compressed tar file has been received at the other end, we can recover all the files using this command:

	  zcat MyProject.tar.Z | tar xvf - 
[Of course, gzip and gunzip can be used instead.]