compress [ -c ] [ -C ] [ -d ] [ -F ] [ -f ] [ -n ] [ -q ] [ -v ] [ -V ] [ -b Bits ] [ File ... ]
The compress command compresses data, using adaptive Lempel-Zev coding to reduce the size of files. Each original file specified by the File parameter is replaced when possible by a compressed file with a .Z appended to its name. The compressed file retains the same ownership, modes, and modification time 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.
Note: Files must have correct permissions to be replaced.
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%. The compression of the compress command is usually more compact and takes less time to compute than the compression achieved by Huffman coding (as used in the pack command) or adaptive Huffman coding.
|-b Bits||Specifies the maximum number of bits to use to replace common substrings in the file. The value of the Bits variable must be in the range from 9 bits through 16 bits, with the default being 16 bits. When compressing data, the algorithm first uses all of the 9-bit codes (257 through 512) to replace as many substrings as possible. Then it uses all 10-bit codes, and so on, continuing until the limit specified by the -b flag is reached.|
|-c||Writes to standard output. No files are changed.|
|-C||Produces output compatible with the Berkeley Software Distribution (BSD) Revision 2.0.|
|-d||Causes the compress command to function exactly like the uncompress command.|
|-f or -F|| Forces compression. The -f and -F flags are interchangeable. Overwrites the File.Z file if it already exists.
After the value of the Bits variable is attained, the compress command periodically checks the compression ratio. If it is increasing, the compress command continues to use the existing code dictionary. However, if the compression ratio decreases, the compress command discards the table of substrings and rebuilds it. Rebuilding the table allows the algorithm to adapt to the next block of the file.
|-n||Omits the compressed file header from the compressed file.|
|-q||Suppresses the display of compression statistics generated by the -v flag. If several -v and -q flags are on the same command line, the last one specified controls the display of the statistics.|
|-v||Writes the percentage of compression.|
|-V||Writes the current version and compile options to standard error.|
|File||Specifies the file to compress.|
If an error occurs, the exit status is 1. If the compress command exits without compressing a file, it exits with a status of 2. Otherwise, the compress command exits with a status of 0.
The compress command detects an error and exits with a status of 1 if any of the following events occur:
|1||An error occurred.|
|2||One or more files were not compressed because they would have increased in size (and the -f flag was not specified).|
|>2||An error occurred.|
To compress the foo file and write the percentage of compression to standard error, enter:
compress -v foo
The foo file is compressed and renamed foo.Z .
The compress command uses the modified Lempel-Zev algorithm described in "A Technique for High Performance Data Compression," Welch, Terry A. IEEE Computer, vol. 17, no. 6 (June 1984), pp. 8-19.
The pack command, uncompress command, unpack command, zcat command.
Commands Overview in AIX Version 4.3 System User's Guide: Operating System and Devices.