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

Commands Reference, Volume 4


pack Command

Purpose

Compresses files.

Syntax

pack-f ] [  ] File ...

Description

The pack command stores the file specified by the File parameter in a compressed form. The input file is replaced by a packed file with the same name and the suffix .z appended. The packed file maintains 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 or pcat commands.

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.

Note: The pack command's algorithm uses Huffman encoding to compress files. This algorithm has fundamental limitations. Consequently, the pack command can only consistently compress files under 8MB. To consistently compress files larger than 8MB, use the compress command.

The exit value of the pack command is the number of files that it could not pack. The pack command does not pack under any of the following conditions:

Flags


-f Forces packing of the file specified by the File parameter. This is useful for packing an entire directory, even if some of the files will not benefit.

Parameters


File Specifies the file to be packed.
- Displays statistics about the file specified by the File parameter. The statistics are calculated from a Huffman minimum redundancy code tree built on a byte-by-byte basis. Additional occurrences of the - (minus sign) parameter on the command line toggles this function for the next specified file. See example 2.

Exit Status

This command returns the following exit values:

0 Specifies that the file was successfully packed.
>0 Specifies that an error occurred.

Examples

  1. To compress the files named chap1 and chap2 and display the revised file names, enter:

    pack chap1 chap2
    

    The compressed versions are renamed chap1.z and chap2.z. The pack command displays the percent decrease in size for each file compressed.

  2. To display statistics about the amount of compression done, enter:
    pack  chap1  chap2
    This compresses the files named chap1 and chap2 and displays statistics about the file named chap1, but not about the file named chap2. The first - (minus sign) parameter turns on the statistic display, and the second - parameter turns it off.

Files


/usr/bin/pack Contains the pack command.

Related Information

The cat command, pcat command, unpack command.

Files Overview in AIX 5L Version 5.1 System User's Guide: Operating System and Devices.

Input and Output Redirection Overview in AIX 5L Version 5.1 System User's Guide: Operating System and Devices.


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