compress(1) — Commands
OSF
NAME
compress, uncompress, zcat − Compresses and expands data
SYNOPSIS
compress [-cCdfFnqvV] [-b bits] [file ...]
uncompress [-cCfFnqvV] [file ...]
zcat [file ...]
FLAGS
-b bitsSpecifies the maximum number of bits to use to replace common substrings in the file. The default for bits is 16, with values of 9 through 16 acceptable. First, the algorithm uses 9-bit codes 257 through 512. Then it uses 10-bit codes, continuing until the bits limit is reached. (This is not permitted with the uncompress command). After the bits limit is attained, the compress command periodically checks the compression ratio. If it is increasing, compress continues to use the existing code dictionary. However, if the compression ratio decreases, compress discards the table of substrings and rebuilds it from the beginning. This allows the algorithm to adapt to the next block of the file. The -b flag must be the last flag on the command line.
-cMakes compress and uncompress write to the standard output; no files are changed. The nondestructive behavior of zcat is identical to that of uncompress -c.
-CProduces output compatible with compress 2.0.
-dUncompresses a file.
-f or -FForces the compression or uncompression of file even if it already exists. If you run the command in the background under /bin/sh or if -f is not specified, you are prompted as to whether an existing file should be overwritten.
-nSpecifies that no header has been added.
-qSpecifies a quiet operation.
-vCauses the percentage reduction of each file to print.
-VSpecifies a version.
DESCRIPTION
The compress command reduces the size of the named files using adaptive Lempel-Ziv coding.
Whenever possible, each file is replaced by one with the extension .Z while keeping the same ownership modes, access, and modification times. If no files are specified, the standard input is compressed to the standard output.
Compressed files can be restored to their original form using the uncompress or zcat command.
The uncompress command replaces the compressed .Z file with an uncompressed version of the file, identical to the file that was originally compressed with compress; the .Z suffix is removed. When issuing an uncompress command, you can refer to the compressed target file with or without the .Z suffix; if you do not specify the suffix, uncompress assumes it.
The zcat command writes the uncompressed version of a compressed file to standard output. The compressed (.Z) files remains intact. zcat is identical to uncompress -c. When issuing a zcat command, you can refer to the compressed target file with or without the .Z suffix; if you do not specify the suffix, zcat assumes it.
The compress command uses the modified Lempel-Ziv algorithm popularized in "A Technique for High Performance Data Compression," Terry A. Welch, IEEE Computer, vol. 17, no. 6 (June 1984), pp. 8-19.
The amount of compression obtained depends on the size of the input, the number of bits per code, and the distribution of common substrings. Typically, files containing source code or plain text are reduced by 50 to 60%. Compression is generally much better than that achieved by Huffman coding (as used in the pack command) or adaptive Huffman coding, and takes less time to compute.
EXAMPLES
To compress folder and print the savings, enter:
compress -v foo
The system responds with a message like:
folder: Compression: 43.94% -- replaced with folder.Z
The following command displays the uncompressed version of the testlog.Z file:
zcat testlog.Z
EXIT VALUES
If an error occurs, exit status is 1; if the last file was not compressed because it became larger, the status is 2; otherwise, the status is 0.
DIAGNOSTICS
Usage: compress [-fvc] [-b maxbits] [file ...]
Invalid arguments were specified on the command line.
Missing maxbits
maxbits must follow -b.
file not in compressed format
file cannot be uncompressed, because it was never compressed.
file compressed with xx bits, can only handle yy bits.
file was compressed by a program that could deal with more bits than the compress code on this machine. Recompress the file with smaller bits.
file already has .Z suffix -- no change
file is assumed to be already compressed. Rename the file and try again.
file already exists; do you wish to overwrite (y or n)?
Respond y, or the locale’s equivalent of a y, if you want the output file to be replaced; n, or the locale’s equivalent of a n, if not. (The LC_MESSAGES variable determines the locale’s equivalent of y or n.)
uncompress: corrupt input
A SIGSEGV violation was detected, which usually means that the input file is corrupted.
Compression: xx.xx%
Percentage of the input saved by compression (relevant only for -v).
-- not a regular file: unchanged
When the input file is not a regular file, (for example, a directory), it is left unaltered.
-- has xx other links: unchanged
The input file has links; it is left unchanged. (See the ln command for more information.)
-- file unchanged
No savings is achieved by compression. The input remains unchanged.
RELATED INFORMATION
Commands: pack(1)/pcat(1)/unpack(1).