Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

compact(1)

pack(1)

acl(5)

compress(1)

NAME

compress, uncompress, zcat, compressdir, uncompressdir − compress and expand data

SYNOPSIS

Compress Files

compress [−d] [−f] [−v] [−c] [−V] [−b maxbits] [name ...]
uncompress [−f] [−v] [−c] [−V] [name ...]
zcat [−V] [name ...]

Compress Entire Directories

compressdir [options] [directory ...]
uncompressdir [options] [directory ...]

DESCRIPTION

compress reduces the size of the named files using adaptive Lempel-Ziv coding.  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 using compress −d, uncompress, or zcat.

compressdir is a front-end processor that recursively descends each specified directory and uses compress(1) to compress each file in directory. Each file is replaced by a compressed file having the same name but with the extension .Z, provided the resulting file is smaller than the original.  If no directories are specified, compression is applied to all files starting with the current directory.  uncompressdir performs the reverse of compressdir, restoring compressed files to their original form. options can include any valid compress command options; they are passed through to compressdir (or uncompressdir).

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 pack), or adaptive Huffman coding (compact), and takes less time to compute.

Exit status is normally 0; if the last file is larger after (attempted) compression, the status is 2; if an error occurs, exit status is 1. 

Options

The following options are recognized:

−d Decompress name. compress −d is equivalent to uncompress.

−f Force compression of name.  This is useful for compressing an entire directory, even if some of the files do not actually shrink.  If −f is not given and compress is run in the foreground, the user is prompted as to whether an existing file should be overwritten. 

−v Print a message describing the percentage of reduction for each file compressed. 

−c Force compress and uncompress to write to the standard output; no files are changed.  The nondestructive behavior of zcat is identical to that of uncompress −c. 

−V Print the current version and compile options onto the standard error. 

−b maxbits Specify the maximum number of bits the compress algorithm will use.  The default is 16 and the range can be any integer between 9 and 16. 

compress 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.  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 −b flag is reached (default 16). 

After the maxbits limit is attained, compress periodically checks the compression ratio.  If it is increasing, compress continues to use the existing code dictionary.  However, if the compression ratio is decreasing, compress 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 −b flag is omitted for uncompress 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 recompression of compressed data is attempted. 

Access Control Lists

compress retains a file’s access control list when compressing and expanding data. 

DIAGNOSTICS

Usage: compress [−dfvcV] [−b maxbits] [file ...]
Invalid options were specified on the command line.

Missing maxbits maxbits must follow −b. 

file: not in compressed format
The file specified to uncompress has not been compressed. 

file: compressed with xx bits, can only handle yy bits
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.

file: already has .Z suffix -- no change
The file is assumed to be already compressed. Rename the file and try again.

file: filename too long to tack on .Z
The output file name, which is the source file name with a .Z extension, is too long for the file system on which the source file resides.  Make the source file name shorter and try again. 

file already exists; do you wish to overwrite (y or n)? 
Respond y if you want the output file to be replaced; n if not. 

uncompress: corrupt input
A SIGSEGV violation was detected which usually means that the input file has been corrupted. 

Compression: xx.xx%
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 ln(1) for more information.

-- file unchanged
No savings is achieved by compression.  The input remains virgin.

EXAMPLES

The command:

compress -v zenith

compresses the file zenith and prints information resembling the following to the screen:

zenith: Compression: 23.55% -- replaced with zenith.Z

indicating that the compressed file is 23.55% smaller than the original, or

zenith: Compression: -12.04% -- file unchanged

indicating that an additional 12.04% space must be used to compress the file. 

To undo the compression, type:

uncompress zenith.Z

or

compress -d zenith.Z

This restores file zenith.Z to its original uncompressed form and name. 

WARNINGS

Although compressed files are compatible between machines with large memory, −b12 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 st_mode by stat(2)), but not copied to the new file.

AUTHOR

compress was developed by Joseph M. Orost, Kenneth E. Turkowski, Spencer W. Thomas, and James A. Woods. 

FILES

∗.Z Compressed file created by compress and removed by uncompress.

SEE ALSO

compact(1), pack(1), acl(5). 

Hewlett-Packard Company  —  HP-UX Release 8.05: June 1991

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026