compress(1)compress(1)NAME
compress, uncompress, zcat, compressdir, uncompressdir - compress and
expand data
SYNOPSIS
Compress Files
maxbits] [file ...]
[file ...]
[file ...]
Compress Entire Directory Subtrees
[options] [directory ...]
[options] [directory ...]
DESCRIPTION
The following commands compress and uncompress files and directory sub‐
trees as indicated:
Reduce the size of the named
files using adaptive Lempel-Ziv coding. If
reduction is possible, each file is replaced
by a new file of the same name with the suf‐
fix added to indicate that it is a com‐
pressed file. Original ownership, modes,
access, and modification times are pre‐
served. If no file is specified, or if is
specified, standard input is compressed to
the standard output.
Restore the compressed
files to original form. Resulting files
have the original filename, ownership, and
permissions, and the filename suffix is
removed. If no file is specified, or if is
specified, standard input is uncompressed to
the standard output.
Restore the compressed
files to original form and send the result
to standard output. If no file is speci‐
fied, or if is specified, standard input is
uncompressed to the standard output.
Front-end processor.
Recursively descend each specified directory
subtree and use to compress each file in
directory. Existing files are replaced by a
compressed file having the same name plus
the suffix provided the resulting file is
smaller than the original. If no directo‐
ries are specified, compression is applied
to all files starting with the current
directory.
options may include any valid command
options (they are passed through to To force
compression of all files, even when the
result is larger than the original file, use
the option.
Opposite of Restore compressed files to their original
form. options may include any valid command
options (they are passed through to
The amount of compression obtained depends on the size of the input,
the maximum number of bits (maxbits) per code, and the distribution of
common substrings. Typically, text such as source code or English is
reduced by 50-60 percent. Compression is generally much better than
that achieved by Huffman coding (as used in or adaptive Huffman coding
and takes less time to compute.
Options
These commands recognize the following options in the combinations
shown above in SYNOPSIS:
Decompress file. is equivalent to
Force compression of
file. This is useful for compressing an
entire directory, even if some of the files
do not actually shrink. If is not given and
is run in the foreground, the user is
prompted as to whether an existing file
should be overwritten.
This is the same as the
option except that it does not force com‐
pression when there is null compression.
Print a message describing the percentage of
reduction for each file compressed.
Force and to write to the standard output; no
files are changed. The nondestructive
behavior of is identical to that of
Print the current version and compile options onto the standard
error.
Specify the maximum number of bits the
algorithm will use. The default is 16 and
the range can be any integer between 9 and
16.
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), pages 8-19. 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 limit specified by the flag is reached (default 16).
After the maxbits limit is attained, periodically checks the compres‐
sion ratio. If it is increasing, continues to use the existing code
dictionary. However, if the compression ratio is decreasing, discards
the table of substrings and rebuilds it from scratch. This allows the
algorithm to adapt to the next "block" of the file.
Note that the flag is omitted for since the maxbits parameter specified
during compression is encoded within the output, along with a magic
number to ensure that neither decompression of random data nor recom‐
pression of compressed data is attempted.
Access Control Lists
retains a file's access control list when compressing and expanding
data.
EXTERNAL INFLUENCES
Environment Variables
determines the language in which messages are displayed.
If is not specified in the environment or is set to the empty string,
the value of is used as a default for each unspecified or empty vari‐
able. If is not specified or is set to the empty string, a default of
"C" (see lang(5)) is used instead of
If any internationalization variable contains an invalid setting, and
behave as if all internationalization variables are set to "C". See
environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported.
RETURN VALUE
These commands return the following values upon completion:
Completed successfully.
Last file is larger after (attempted) compression.
An error occurred.
DIAGNOSTICS
Invalid options were specified on the command line.
maxbits
must follow
The file specified to
has not been compressed.
file was compressed by a program that could deal with a higher value
of maxbits than the compress code on this machine. Recompress
the file with a lower value of maxbits.
The file is assumed to be already compressed.
Rename the file and try again.
The output file name, which is the source file name with a
extension, is too long for the file system on which the source
file resides. Make the source file name shorter and try again.
Respond
if you want the output to replace the existing file; otherwise,
respond
A violation was detected which usually means that the input file
has been corrupted.
Percentage of the input saved by compression.
(Relevant only for
When the input file is not a regular file (a directory for example),
it is left unaltered.
The input file has links which are not symbolic links and has been
left unchanged. See ln(1) for more information.
The input file has symbolic links and has been left unchanged.
See ln(1) for more information.
No savings is achieved by compression.
The input remains unaltered.
EXAMPLES
Compress the file named and print compression information to the termi‐
nal:
The terminal display shows either a line resembling
indicating that the compressed file is 23.55% smaller than the origi‐
nal, or a line resembling
indicating that an additional 12.04% space must be used to compress the
file.
Undo the compression by typing either of the following commands:
This restores file to its original uncompressed form and name.
will perform on standard input if no files are specified. For example,
to list a compressed tar file:
WARNINGS
Although compressed files are compatible between machines with large
memory, should be used for file transfer to architectures with a small
process data space (64K bytes or less).
NFS
Access control lists of networked files are summarized (as returned in
by but not copied to the new file (see stat(2)).
AUTHOR
was developed by Joseph M. Orost, Kenneth E. Turkowski, Spencer W.
Thomas, and James A. Woods.
FILES
Compressed file created by
and removed by
SEE ALSOcompact(1), pack(1), acl(5).
STANDARDS CONFORMANCEcompress(1)