compress, uncompress, zcat - Compresses and expands data
compress [-cCdfFnqvV] [-b bits] [file...]
uncompress [-cCfFnqvV] [file...]
zcat [-n] [file...]
Interfaces documented on this reference page conform to industry standards
Refer to the standards(5) reference page for more information about indus-
try standards and associated tags.
Specifies the maximum number of bits to use to replace common sub-
strings 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 option applies to the compress command only.)
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 lets the algorithm adapt to the next block of
[Tru64 UNIX] The -b option must be the last option on the command
-c Makes compress and uncompress write to the standard output; no files
are changed. The nondestructive behavior of zcat is identical to that
of uncompress -c.
-C [Tru64 UNIX] Produces output compatible with compress 2.0.
-d [Tru64 UNIX] Uncompresses a file.
-f or -F
When used with the compress command, forces the compression of file
even if no reduction in the size of the file will occur.
With both the compress and uncompress commands, if you run the command
in the background and -f is not specified, you are prompted as to
whether an existing file should be overwritten.
-n [Tru64 UNIX] Specifies that no header has been added.
-q [Tru64 UNIX] Specifies a quiet operation. This is the default. Diag-
nostics messages, which display if you specify the -v option, do not
print. If the -q and -v options are both specified, the last one on the
command line is honored.
-v Prints the percentage reduction of each file when compressing the file.
Prints messages to standard error concerning the expansion of each file
when uncompressing the file. If the -q and -v options are both speci-
fied, the last one on the command line is honored.
-V [Tru64 UNIX] Specifies a version.
The path name of a file to be processed. If - (hyphen) is used, stan-
dard input will be read.
The compress command will create an output file name by appending a
suffix of .Z to the input file name.
With the uncompress and zcat commands, if the file name has a .Z suf-
fix, the command will look for a file of that name. If the suffix is
not specified, the command will append the .Z suffix before searching
for the file.
The uncompress command will store output in a file named with the .Z
suffix removed if it was specified. If no .Z suffix is specified, the
uncompress command will accept file as the name of the output file and
append a .Z suffix before searching for the file.
The compress command reduces the size of the named files using adaptive
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, standard input is compressed to the standard output.
Compressed files can be restored to their original form by 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 com-
mand, 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 remain intact. The zcat command
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.
[Tru64 UNIX] 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 percent. 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.
[Tru64 UNIX] The compress command may not preserve the extended file
attributes (property list) of a file, including the access control list
(ACL) if any. Verify that any ACLs have not been removed or modified after
using compress or uncompress.
The following exit values are returned:
0 Successful completion.
1 An error occurred.
2 One or more files were not compressed because they became larger.
>>2 An error occurred.
uncompress and zcat commands
0 Successful completion.
>>0 An error occurred.
Usage: compress [-fvc] [-b maxbits] [file ...]
Invalid arguments were specified on the command line.
maxbits must follow -b.
file not in compressed format
The file cannot be uncompressed because it was never compressed.
file compressed with xx bits, can only handle yy bits.
The file was compressed by a program that could deal with more bits
than the compress code on this machine. Recompress the file with
file already has .Z suffix -- no change
file is assumed to be already compressed. Rename the file and try
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
uncompress: corrupt input
A SIGSEGV violation was detected, which usually means that the input
file is corrupted.
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 saving is achieved by compression. The input remains unchanged.
1. To compress folder and print the savings, enter:
compress -v folder
The system responds with a message like:
folder: Compression: 43.94% -- replaced with folder.Z
2. The following command displays the uncompressed version of the
The following environment variables affect the execution of compress,
uncompress, and zcat:
Provides a default value for the internationalization variables that
are unset or null. If LANG is unset or null, the corresponding value
from the default locale is used. If any of the internationalization
variables contain an invalid setting, the utility behaves as if none of
the variables had been defined.
If set to a non-empty string value, overrides the values of all the
other internationalization variables.
Determines the locale for the interpretation of sequences of bytes of
text data as characters (for example, single-byte as opposed to multi-
byte characters in arguments).
Determines the locale for the format and contents of diagnostic mes-
sages written to standard error.
Determines the location of message catalogues for the processing of
Commands: pack(1), pcat(1), unpack(1)