.\" Copyright (c) 1986, 1990 The Regents of the University of California.
.\" This code is derived from software contributed to Berkeley by
.\" James A. Woods, derived from original work by Spencer Thomas
.\" %sccs.include.redist.man%
.\" @(#)compress.1 6.12 (Berkeley) %G%
.Nd compress and expand data
reduces the size of the named files using adaptive Lempel-Ziv coding.
is renamed to the same name plus the extension
As many of the modification time, access time, file flags, file mode,
user ID, and group ID as allowed by permissions are retained in the
If compression would not reduce the size of a
restores the compressed files to their original form, renaming the
If renaming the files would cause files to be overwritten and the standard
input device is a terminal, the user is prompted (on the standard error
output) for confirmation.
If prompting is not possible or confirmation is not received, the files
If no files are specified, the standard input is compressed or uncompressed
If either the input and output files are not regular files, the checks for
reduction in size and file overwriting are not performed, the input file is
not removed, and the attributes of the input file are not retained.
The options are as follows:
Compressed or uncompressed output is written to the standard output.
even if it is not actually reduced in size.
Additionally, files are overwritten without prompting for confirmation.
Print the percentage reduction of each file.
uses a modified Lempel-Ziv algorithm.
Common substrings in the file are first replaced by 9-bit codes 257 and up.
When code 512 is reached, the algorithm switches to 10-bit codes and
continues to use more bits until the
flag is reached (the default is 16).
must be between 9 and 16.
periodically checks the compression ratio.
continues to use the existing code dictionary.
However, if the compression ratio decreases,
discards the table of substrings and rebuilds it from scratch. This allows
the algorithm to adapt to the next "block" of the file.
parameter specified during compression
is encoded within the output, along with
a magic number to ensure that neither decompression of random data nor
recompression of compressed data is attempted.
The amount of compression obtained depends on the size of the
per code, and the distribution of common substrings.
Typically, text such as source code or English is reduced by 50\-60%.
Compression is generally much better than that achieved by Huffman
coding (as used in the historical command pack), or adaptive Huffman
coding (as used in the historical command compact), and takes less
utility exits 0 on success, and >0 if an error occurs.
.%T "A Technique for High Performance Data Compression"