1COMPRESS(1P)               POSIX Programmer's Manual              COMPRESS(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       compress - compress data
13

SYNOPSIS

15       compress [-fv][-b bits][file ...]
16
17       compress [-cfv][-b bits][file]
18
19

DESCRIPTION

21       The compress utility shall attempt to reduce  the  size  of  the  named
22       files by using adaptive Lempel-Ziv coding algorithm.
23
24       Note:  Lempel-Ziv  is  US  Patent  4464650,  issued to William Eastman,
25              Abraham Lempel, Jacob Ziv, Martin Cohn on August 7th, 1984,  and
26              assigned to Sperry Corporation.
27
28       Lempel-Ziv-Welch compression is covered by US Patent 4558302, issued to
29       Terry A. Welch on December 10th, 1985, and assigned to Sperry  Corpora‐
30       tion.
31
32       On  systems  not  supporting  adaptive Lempel-Ziv coding algorithm, the
33       input files shall not be changed and an error value  greater  than  two
34       shall  be  returned.  Except when the output is to the standard output,
35       each file shall be replaced by one with the extension .Z. If the invok‐
36       ing  process  has  appropriate privileges, the ownership, modes, access
37       time, and modification time of the  original  file  are  preserved.  If
38       appending  the .Z to the filename would make the name exceed {NAME_MAX}
39       bytes, the command shall fail. If no files are specified, the  standard
40       input shall be compressed to the standard output.
41

OPTIONS

43       The  compress  utility  shall conform to the Base Definitions volume of
44       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
45
46       The following options shall be supported:
47
48       -b  bits
49              Specify the maximum number of bits to use in a code. For a  con‐
50              forming application, the bits argument shall be:
51
52
53              9 <= bits <= 14
54
55       The  implementation  may  allow  bits  values  of greater than 14.  The
56       default is 14, 15, or 16.
57
58       -c     Cause compress to write to the standard output; the  input  file
59              is not changed, and no .Z files are created.
60
61       -f     Force  compression  of file, even if it does not actually reduce
62              the size of the file, or  if  the  corresponding  file  .Z  file
63              already  exists.  If the -f option is not given, and the process
64              is not running in the background, the user  is  prompted  as  to
65              whether an existing file .Z file should be overwritten.
66
67       -v     Write the percentage reduction of each file to standard error.
68
69

OPERANDS

71       The following operand shall be supported:
72
73       file   A pathname of a file to be compressed.
74
75

STDIN

77       The  standard  input  shall be used only if no file operands are speci‐
78       fied, or if a file operand is '-' .
79

INPUT FILES

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

ENVIRONMENT VARIABLES

85       The  following environment variables shall affect the execution of com‐
86       press:
87
88       LANG   Provide a default value for the  internationalization  variables
89              that  are  unset  or  null.  (See the Base Definitions volume of
90              IEEE Std 1003.1-2001, Section  8.2,  Internationalization  Vari‐
91              ables  for the precedence of internationalization variables used
92              to determine the values of locale categories.)
93
94       LC_ALL If set to a non-empty string value, override the values  of  all
95              the other internationalization variables.
96
97       LC_CTYPE
98              Determine  the  locale  for  the  interpretation of sequences of
99              bytes of text data as characters (for  example,  single-byte  as
100              opposed to multi-byte characters in arguments).
101
102       LC_MESSAGES
103              Determine  the  locale  that should be used to affect the format
104              and contents of diagnostic messages written to standard error.
105
106       NLSPATH
107              Determine the location of message catalogs for the processing of
108              LC_MESSAGES .
109
110

ASYNCHRONOUS EVENTS

112       Default.
113

STDOUT

115       If  no  file operands are specified, or if a file operand is '-', or if
116       the -c option is specified, the standard output contains the compressed
117       output.
118

STDERR

120       The  standard  error  shall be used only for diagnostic and prompt mes‐
121       sages and the output from -v.
122

OUTPUT FILES

124       The output files shall contain the compressed  output.  The  format  of
125       compressed  files  is unspecified and interchange of such files between
126       implementations (including access via unspecified file  sharing  mecha‐
127       nisms) is not required by IEEE Std 1003.1-2001.
128

EXTENDED DESCRIPTION

130       None.
131

EXIT STATUS

133       The following exit values shall be returned:
134
135        0     Successful completion.
136
137        1     An error occurred.
138
139        2     One  or  more  files were not compressed because they would have
140              increased in size (and the -f option was not specified).
141
142       >2     An error occurred.
143
144

CONSEQUENCES OF ERRORS

146       The input file shall remain unmodified.
147
148       The following sections are informative.
149

APPLICATION USAGE

151       The amount of compression obtained depends on the size  of  the  input,
152       the number of bits per code, and the distribution of common substrings.
153       Typically, text such as source code or English is  reduced  by  50-60%.
154       Compression is generally much better than that achieved by Huffman cod‐
155       ing or adaptive Huffman coding ( compact), and takes less time to  com‐
156       pute.
157
158       Although  compress strictly follows the default actions upon receipt of
159       a signal or when an error occurs, some unexpected results may occur. In
160       some  implementations  it is likely that a partially compressed file is
161       left in place, alongside its uncompressed input file. Since the general
162       operation of compress is to delete the uncompressed file only after the
163       .Z file has been successfully  filled,  an  application  should  always
164       carefully check the exit status of compress before arbitrarily deleting
165       files that have like-named neighbors with .Z suffixes.
166
167       The limit of 14 on the bits option-argument is to  achieve  portability
168       to  all  systems  (within  the  restrictions  imposed by the lack of an
169       explicit published file format). Some implementations based  on  16-bit
170       architectures cannot support 15 or 16-bit uncompression.
171

EXAMPLES

173       None.
174

RATIONALE

176       None.
177

FUTURE DIRECTIONS

179       None.
180

SEE ALSO

182       uncompress, zcat
183
185       Portions  of  this text are reprinted and reproduced in electronic form
186       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
187       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
188       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
189       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
190       event of any discrepancy between this version and the original IEEE and
191       The  Open Group Standard, the original IEEE and The Open Group Standard
192       is the referee document. The original Standard can be  obtained  online
193       at http://www.opengroup.org/unix/online.html .
194
195
196
197IEEE/The Open Group                  2003                         COMPRESS(1P)
Impressum