The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

compress - compress data

 SYNOPSIS



compress [-fv][-b bits][file ...] 

compress [-cfv][-b bits][file] 

 DESCRIPTION

The compress utility will attempt to reduce the size of the named files by using adaptive Lempel-Ziv coding. Except when the output is to the standard output, each file will be replaced by one with the extension .Z. If the invoking process has appropriate privileges, the ownership, modes, access time, and modification time of the original file are preserved. If appending the .Z to the filename would make the name exceed {NAME_MAX} bytes, the command will fail. If no files are specified, the standard input will be compressed to the standard output.

 OPTIONS

The compress utility supports the XBD specification, Utility Syntax Guidelines  .

The following options are supported:

-b bits
Specify the maximum number of bits to use in a code. For a portable application, the bits argument must be:
9 >= bits <= 14

The implementation may allow bits values of greater than 14. The default will be 14, 15 or 16.

-c
Cause compress to write to the standard output; the input file will not be changed, and no .Z files will be created.
-f
Force compression of file, even if it does not actually reduce the size of the file, or if the corresponding file.Z file already exists. If the -f option is not given, and the process is not running in the background, the user will be prompted as to whether an existing file.Z file should be overwritten.
-v
Write the percentage reduction of each file to standard error.

 OPERANDS

The following operand is supported:
file
A pathname of a file to be compressed.

 STDIN

The standard input will be used only if no file operands are specified, or if a file operand is "-".

 INPUT FILES

If file operands are specified, the input files contain the data to be compressed.

 ENVIRONMENT VARIABLES

The following environment variables affect the execution of compress:
LANG
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
LC_ALL
If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
NLSPATH
Determine the location of message catalogues for the processing of LC_MESSAGES .

 ASYNCHRONOUS EVENTS

Default.

 STDOUT

If no file operands are specified, or if a file operand is "-", or if the -c option is specified, the standard output will contain the compressed output.

 STDERR

Used for all diagnostic and prompt messages and the output from -v.

 OUTPUT FILES

The output files will contain the compressed output.

 EXTENDED DESCRIPTION

None.

 EXIT STATUS

The following exit values are returned:
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.

 CONSEQUENCES OF ERRORS

The input file will remain unmodified.

 APPLICATION USAGE

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, text such as source code or English is reduced by 50-60%. 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.

Although compress strictly follows the default actions upon receipt of a signal or when an error occurs, some unexpected results may occur. In some implementations it is likely that a partially compressed file will be left in place, alongside its uncompressed input file. Since the general operation of compress is to delete the uncompressed file only after the .Z file has been successfully filled, an application should always carefully check the exit status of compress before arbitrarily deleting files that have like-named neighbours with .Z suffixes.

Compressed files are not necessarily portable to other systems.

The limit of 14 on the bits option-argument is to achieve portability to all systems (within the restrictions imposed by the lack of an explicit published file format). Some systems based on 16-bit architectures cannot support 15- or 16-bit uncompression.

 EXAMPLES

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

uncompress, zcat.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]