Compressing files using the pack command
Use the pack command to store the file or files specified by the File parameter in a compressed form using Huffman coding.
The input file is replaced by a packed file with a name derived from the original file name (File.z), with the same access modes, access and modification dates, and owner as the original file. The input file name can contain no more than 253 bytes to allow space for the added .z suffix. If the pack command is successful, the original file is removed.
Use the unpack command to restore packed files to their original form.
If the pack command cannot create a smaller file, it stops processing and reports that it is unable to save space. (A failure to save space generally happens with small files or files with uniform character distribution.) The amount of space saved depends on the size of the input file and the character frequency distribution. Because a decoding tree forms the first part of each .z file, you do not save space with files smaller than three blocks. Typically, text files are reduced 25 to 40 percent.
The exit value of the pack command is the number of files that it could not pack. Packing is not done under any of the following conditions:
- The file is already packed.
- The input file name has more than 253 bytes.
- The file has links.
- The file is a directory.
- The file cannot be opened.
- No storage blocks are saved by packing.
- A file named File.z already exists.
- The .z file cannot be created.
- An I/O error occurred during processing.
pack chap1 chap2
This
compresses chap1 and chap2 and replaces
them with files named chap1.z and chap2.z.
The pack command displays the percent decrease in size
for each file.