compress bigfile.txtand this will create a new file named bigfile.txt.Z. The original file, bigfile.txt, is deleted.
uncompress bigfile.txt.Zwill create the file bigfile.txt (with the same contents as before) and will delete bigfile.txt.Z.
uncompress < bigfile.txt.Z | moreThis is such a common operation that an additional Unix command named zcat has been created. For example:
zcat bigfile.txt.Z | moreis equivalent to the previous command.
Here are some examples of its usage:
Gzip usually produces better compression than compress, and it executes significantly faster.
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.
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.ZThe 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.]