compress

Lempel-Ziv compression of a file

Command


SYNOPSIS

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 the standard input and writes the compressed result to the standard output.

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 you whether or not 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

compress accepts the following options:
-A

lists all entries including those starting with periods (.), but excluding any . or .. entries.

-b bits

limits the maximum number of bits of compression to bits. The value bits may be an integer from 9 to 16. The default is 16.

-c

writes the output to the standard output. 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.


DIAGNOSTICS

Possible exit status values are:
0

Successful completion.

1

An error occurred.

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 including the ability to compress in place, is often found on UNIX systems.

The -D option is an extension to traditional implementations of compress.


SEE ALSO

Commands:
cpio, pack, pax, tar, uncompress, unpack, zcat


Updated MKS Toolkit [3khat16.ico]HP3000 [3khat16.ico]3kMail [archive16.gif]