Format
compress [–cDdfVv]
[–b bits] [file
…]
Description
compress compresses
each input file using Lempel-Ziv compression techniques. If you
do not specify any input files, compress reads
data from standard input (stdin) and writes the compressed
result to standard output (stdout).
The output files
have the same names as the input files but with a .Z suffix.
For example, abc is compressed into abc.Z.
If the .Z file already exists and you did
not specify the –f option, compress gives
an error and asks whether it should overwrite the existing file.
compress uses
the modified Lempel-Ziv algorithm described in A Technique for
High Performance Data Compression, Terry A. Welch, IEEE
Computer, vol. 17, no. 6 (June 1984), pp.8-19. compress first
replaces common substrings in the file by 9-bit codes starting at
257. After it reaches code 512, compress begins
with 10-bit codes and continues to use more bits until it reaches
the limit set by the –b option.
After
attaining the bits limit, compress 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 scratch. This allows the algorithm
to compensate for files, such as archives, where individual components
have different information content profiles.
Options
- –b bits
- Limits the maximum number of bits of compression to bits.
The value bits can be an integer from 9
to 16. The default is 16.
- –c
- Writes the output to stdout. When you use this option,
you can only specify one file on the command line.
- –D
- Allows an extra degree of compression to be done for files such
as sorted dictionaries where subsequent lines normally have many characters
in common with the preceding line.
- –d
- Decompresses argument files instead of compressing them. This
works by overlaying the compress program
with the uncompress program. For this to
work, uncompress must be available somewhere
in your search path (given by the PATH environment variable).
Decompressing files this way is slower than calling uncompress directly.
- –f
- Forces compression even if the resulting file is larger or the
output file already exists. When you do not specify this option, files
which are larger after compression are not compressed. compress does
not print an error message if this happens.
- –V
- Prints the version number of compress.
- –v
- Prints statistics giving the amount of compression achieved. Statistics
give the name of each file compressed and the compression ratio, expressed
as a percentage. If the file resulting from compression is larger
than the original, the compression ratio is negative.
Localization
compress uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
- NLSPATH
See Localization for more
information.
Exit values
- 0
- Successful completion
- 1
- Failure due to one of the following:
- Missing number of bits after the –b option
- Incorrect number of bits specified
- Failed to execute uncompress
- Unknown option
- Dictionary option —same count of string exceeded
- Output path or file name too long
- Cannot stat file
- Argument file not a regular file: unchanged
- Argument file has other links: unchanged
- No space for compression tables
- 2
- One or more files were not compressed because the compressed version
was larger than the original
Limits
This implementation of compress is
limited to a maximum of 16-bit compression.
Portability
A binary-compatible version
of compress with more options is often found
on UNIX systems.
The –D option
is an extension to traditional implementations of compress.
The –D, –d and –V options
are extensions of the POSIX standard.
For portability, you
should restrict the number of bits in the code (–b option)
to a value between 9 and 14.
Related information
cpio, pack, pax, tar, uncompress, unpack, zcat