I had a situation today that required me to convert a compressed file from a .Z ( adaptive Lempel-Ziv coding ) to a .gz (Lempel-Ziv coding) file to save space. While reading through the gzip documentation, I stumbled across the znew(1) command. This command allows you to switch between file compression types with a single command:
$ znew -K -P -v -9 file.Z
77.2%
One this completed, I had the following files in my home directory:
-rw-r--r-- 1 matty matty 272826735 May 6 15:46 file.Z
-rw-r--r-- 1 matty matty 200377928 May 6 15:46 file.gz
This example uses several options. The “-P” option instructs znew to use pipes to transfer data between code segments, the “-K” options forces znew to keep .Z files if they are smaller than the original gzip’ed file, and the “-v” option displays verbose output. The difference in compressed file sizes leads me to wonder what “adaptive” is adapting to! :)