next up previous

3.1.4 Text Compression and File Archives     continued...

Unfortunately tar will create the new archive file and then start collecting things to put in it. Since you told it to include everything in the current directory, and the current directory now includes the new archive file, tar will be caught in an infinite loop when it adds the archive to itself.

There are other tar commands, including commands to append files to existing archives. Carefully read the man pages for tar (and preferably talk to someone who has built archives) before you build your own archive file.

The Unix utilities that compress and decompress files are based on the Lempel-Zev text compression algorithm [7]. A common pair of programs to compress and expand files are called compress and uncompress, respectively. Both replace their input files by their output. For example, if you compress a file named foo, it will be deleted and in its place you will find foo.Z. Here is an example of how to compress and expand a file:

$ ls -l networks.*  
-rw-r--r-- 1 conery faculty 564433 Aug 18 15:38 networks.mif  
$ compress networks.mif 
$ ls -l networks.*   
-rw-r--r-- 1 conery faculty 129856 Aug 18 15:38 networks.mif.Z 
$ uncompress networks.mif.Z  
$ ls -l networks.*  
-rw-r--r-- 1 conery faculty 564433 Aug 18 15:38 networks.mif