compress(C)


compress, uncompress, zcat -- compress data for storage, uncompress and display compressed files

Syntax

compress [ -cdfFqv ] [ -H | -b bits ] [ file | -P fd ]

uncompress [ -cfFqv ] [ file | -P fd ]

zcat [file]

Description

The compress command takes a file and compresses it to a smaller size (without loss of information), creates a compressed output file, and removes the original file unless the -c option is present. Compression is achieved by encoding common strings within the file.

uncompress restores a previously compressed file to its uncompressed state and removes the compressed version.

zcat uncompresses and displays a file on the standard output. If no file is specified, zcat reads from the standard input.

compress deals with input and output files depending on the arguments specified:


file
compress reads file, compresses it, and places the output in a file of the same name with the suffix .Z appended. If the standard output is redirected (for example, into a pipe), compress sends its output to the standard output, and no .Z file is created.

-P fd
compress reads a list of filenames from the pipe associated with the file descriptor fd. One filename is read from each successive 1K block of data in the pipe. Each filename is null terminated. Filenames are read until a null character is encountered at the beginning of a block or the pipe is closed. Each file is then compressed. The output files have the same name as, and overwrite, the original files. This option can also be used with uncompress.
By default, if no filename is specified as an argument, compress reads from the standard input, compresses it, and sends its output to the standard output.

Files created by compress have the same permissions and ownership as the corresponding input files, or the user's standard permissions if output is directed through the standard output.

If no space is saved by compression, compress will not write an output file unless the -F flag is present on the command line.

If you attempt to compress a symbolic link, the link will be broken and a compressed copy of the file to which the symbolic link pointed will be created locally. compress will fail on a file with hard (non-symbolic) links.

Options

The following options are available from the command line:

-b bits
Specifies the maximum number of bits to use in encoding.

-c
Writes output on the standard output and does not remove original file.

-d
Decompresses a compressed file.

-f
Overwrites previous output file. Writes output file even if compression saves no space.

-F
Overwrites previous output file. Writes output file even if compression saves no space.

-H
Compresses a file by approximately a further 20% based on the LZH algorithm. uncompress(C) automatically detects when files have been compressed with this option and processes them accordingly.

-q
Generates no output except error messages, if any.

-v
Prints the name of the file being compressed, and the percentage of compression achieved. With uncompress, the name of the uncompressed file is printed.

Exit values

compress, uncompress and zcat return the following values:

0
successful completion

1
an error occurred

2
one or more files were not compressed because they would have increased in size (and the -f option was not specified)

>2
an error occurred

Limitations

The -P option is provided for internal use by tar(C).

The -v option is not compatible with the -c option.

compress uses a version of Lempel-Ziv encoding to reduce the redundancy of information stored in files. A variable length sequence of bits is used to represent each character string encountered in the file; in general, the more frequently the string occurs, the less bits are used to represent it. The ratio of the size of the compressed file to the size of the uncompressed original depends on the type of file. Database files tend to shrink dramatically, while short files or some binaries may shrink very little.

Decompression is controlled by a two byte magic number at the start of a compressed file: this is 1F 9D for a standard (Lempel-Ziv-Welch) compressed file, and 1F A0 for a LZH (Lempel-Ziv-Huffman) compressed file. Implementations of compress on other systems may not recognize LZH compressed files.

Open UNIX 8 compatibility notes

When running ACP on Open UNIX 8 and UnixWare 7 systems, set OSRCMDS=on to use the SCO OpenServer version of the <compress>, uncompress, and zcat commands. This provides the expected behaviors for SCO OpenServer applications. The SCO OpenServer version of this command is also provided on Open UNIX 8 systems under the OSP feature See the Running SCO OpenServer Applications topic in the Open UNIX 8 documentation set.

See also

cat(C), pack(C), tar(C)

Standards conformance

compress, uncompress and zcat are conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.

Portions of this code used for Lempel-Ziv-Huffman encoding were based on Rahul Dhesi's zoo archiver which was adapted from Haruhiko Okumura's ar archiver. The SCO OpenServer implementation of LZH compression may not be interoperable with other implementations.

Notices

Versions of compress, uncompress, and zcat that can handle files greater than 2GB are available in /u95/bin. See compress(1) for more information.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005