.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved .TH "COMPRESS" 1P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" .\" compress .SH NAME compress \- compress data .SH SYNOPSIS .LP \fBcompress\fP \fB[\fP\fB-fv\fP\fB][\fP\fB-b\fP \fIbits\fP\fB][\fP\fIfile\fP \fB\&...\fP\fB]\fP\fB .br .sp compress\fP \fB[\fP\fB-cfv\fP\fB][\fP\fB-b\fP \fIbits\fP\fB][\fP\fIfile\fP\fB]\fP\fB\fP \fB .br \fP .SH DESCRIPTION .LP The \fIcompress\fP utility shall attempt to reduce the size of the named files by using adaptive Lempel-Ziv coding algorithm. .TP 7 \fBNote:\fP Lempel-Ziv is US Patent 4464650, issued to William Eastman, Abraham Lempel, Jacob Ziv, Martin Cohn on August 7th, 1984, and assigned to Sperry Corporation. .LP Lempel-Ziv-Welch compression is covered by US Patent 4558302, issued to Terry A. Welch on December 10th, 1985, and assigned to Sperry Corporation. .sp On systems not supporting adaptive Lempel-Ziv coding algorithm, the input files shall not be changed and an error value greater than two shall be returned. Except when the output is to the standard output, each file shall be replaced by one with the extension \fB.Z\fP. If the invoking process has appropriate privileges, the ownership, modes, access time, and modification time of the original file are preserved. If appending the \fB.Z\fP to the filename would make the name exceed {NAME_MAX} bytes, the command shall fail. If no files are specified, the standard input shall be compressed to the standard output. .SH OPTIONS .LP The \fIcompress\fP utility shall conform to the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines. .LP The following options shall be supported: .TP 7 \fB-b\ \fP \fIbits\fP Specify the maximum number of bits to use in a code. For a conforming application, the \fIbits\fP argument shall be: .sp .RS .nf \fB9 <=\fP \fIbits\fP \fB<= 14 \fP .fi .RE .LP The implementation may allow \fIbits\fP values of greater than 14. The default is 14, 15, or 16. .TP 7 \fB-c\fP Cause \fIcompress\fP to write to the standard output; the input file is not changed, and no \fB.Z\fP files are created. .TP 7 \fB-f\fP Force compression of \fIfile\fP, even if it does not actually reduce the size of the file, or if the corresponding \fIfile\fP \fB\&.Z\fP file already exists. If the \fB-f\fP option is not given, and the process is not running in the background, the user is prompted as to whether an existing \fIfile\fP \fB.Z\fP file should be overwritten. .TP 7 \fB-v\fP Write the percentage reduction of each file to standard error. .sp .SH OPERANDS .LP The following operand shall be supported: .TP 7 \fIfile\fP A pathname of a file to be compressed. .sp .SH STDIN .LP The standard input shall be used only if no \fIfile\fP operands are specified, or if a \fIfile\fP operand is \fB'-'\fP \&. .SH INPUT FILES .LP If \fIfile\fP operands are specified, the input files contain the data to be compressed. .SH ENVIRONMENT VARIABLES .LP The following environment variables shall affect the execution of \fIcompress\fP: .TP 7 \fILANG\fP Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of IEEE\ Std\ 1003.1-2001, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) .TP 7 \fILC_ALL\fP If set to a non-empty string value, override the values of all the other internationalization variables. .TP 7 \fILC_CTYPE\fP Determine 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). .TP 7 \fILC_MESSAGES\fP Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. .TP 7 \fINLSPATH\fP Determine the location of message catalogs for the processing of \fILC_MESSAGES \&.\fP .sp .SH ASYNCHRONOUS EVENTS .LP Default. .SH STDOUT .LP If no \fIfile\fP operands are specified, or if a \fIfile\fP operand is \fB'-'\fP , or if the \fB-c\fP option is specified, the standard output contains the compressed output. .SH STDERR .LP The standard error shall be used only for diagnostic and prompt messages and the output from \fB-v\fP. .SH OUTPUT FILES .LP The output files shall contain the compressed output. The format of compressed files is unspecified and interchange of such files between implementations (including access via unspecified file sharing mechanisms) is not required by IEEE\ Std\ 1003.1-2001. .SH EXTENDED DESCRIPTION .LP None. .SH EXIT STATUS .LP The following exit values shall be returned: .TP 7 \ 0 Successful completion. .TP 7 \ 1 An error occurred. .TP 7 \ 2 One or more files were not compressed because they would have increased in size (and the \fB-f\fP option was not specified). .TP 7 >2 An error occurred. .sp .SH CONSEQUENCES OF ERRORS .LP The input file shall remain unmodified. .LP \fIThe following sections are informative.\fP .SH APPLICATION USAGE .LP The amount of compression obtained depends on the size of the input, the number of \fIbits\fP 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 or adaptive Huffman coding ( \fIcompact\fP), and takes less time to compute. .LP Although \fIcompress\fP 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 is left in place, alongside its uncompressed input file. Since the general operation of \fIcompress\fP is to delete the uncompressed file only after the \fB.Z\fP file has been successfully filled, an application should always carefully check the exit status of \fIcompress\fP before arbitrarily deleting files that have like-named neighbors with \fB.Z\fP suffixes. .LP The limit of 14 on the \fIbits\fP option-argument is to achieve portability to all systems (within the restrictions imposed by the lack of an explicit published file format). Some implementations based on 16-bit architectures cannot support 15 or 16-bit uncompression. .SH EXAMPLES .LP None. .SH RATIONALE .LP None. .SH FUTURE DIRECTIONS .LP None. .SH SEE ALSO .LP \fIuncompress\fP , \fIzcat\fP .SH COPYRIGHT Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .