[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

System User's Guide: Operating System and Devices


Compressing Files (compress and pack Commands)

You can compress files for storage with the compress Command and pack Command, and use the uncompress Command and unpack Command to expand the restored files. The process of compressing and expanding files takes time but, once packed, the data uses less space on the backup medium.

There are several methods of compressing a file system:

There are many reasons for compressing files, but generally they fall into two categories:

compress Command

The compress command reduces the size of files using adaptive Lempel-Zev coding. Each original file specified by the File parameter is replaced by a compressed file with a .Z appended to its name. The compressed file retains the same ownership, modes, and access and modification times of the original file. If no files are specified, the standard input is compressed to the standard output. If compression does not reduce the size of a file, a message is written to standard error and the original file is not replaced.

Compressed files can be restored to their original form using the uncompress command.

The amount of compression depends on the size of the input, the number of bits per code specified by the Bits variable, and the distribution of common substrings. Typically, source code or English text is reduced by 50 to 60 percent. The compression of the compress command is generally more compact and takes less time to compute than the compression achieved by the pack command which uses adaptive Huffman coding.

For example, to compress the foo file and write the percentage compression to standard error, type:

compress -v foo

Press Enter.

See the compress command in theAIX 5L Version 5.1 Commands Reference for the exact syntax.

pack Command

The pack command stores 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. Packed files can be restored to their original form using the unpack command.

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:

For example, to compress the files chap1 and chap2, type:

pack chap1 chap2

Press Enter.

This compresses chap1 and chap2, replacing them with files named chap1.z and chap2.z. The pack command displays the percent decrease in size for each file.

See the pack command in theAIX 5L Version 5.1 Commands Reference for more information and the exact syntax.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]