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
11

NAME

13       compress — compress data
14

SYNOPSIS

16       compress [−fv] [−b bits] [file...]
17
18       compress [−cfv] [−b bits] [file]
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,
26                 and assigned to Sperry Corporation.
27
28                 Lempel-Ziv-Welch compression is covered by US Patent 4558302,
29                 issued to Terry A. Welch on December 10th, 1985, and assigned
30                 to Sperry Corporation.
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
36       invoking  process  has  appropriate  privileges,  the ownership, modes,
37       access time, and modification time of the original file are  preserved.
38       If  appending  the  .Z  to  the  filename  would  make  the name exceed
39       {NAME_MAX} bytes, the command shall fail. If no  files  are  specified,
40       the standard input shall be compressed to the standard output.
41

OPTIONS

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

OPERANDS

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

STDIN

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

INPUT FILES

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

ENVIRONMENT VARIABLES

84       The following environment variables shall affect the execution of  com‐
85       press:
86
87       LANG      Provide  a  default  value for the internationalization vari‐
88                 ables that are unset or null. (See the Base Definitions  vol‐
89                 ume  of POSIX.1‐2008, Section 8.2, Internationalization Vari‐
90                 ables for the precedence  of  internationalization  variables
91                 used to determine the values of locale categories.)
92
93       LC_ALL    If  set  to  a non-empty string value, override the values of
94                 all the other internationalization variables.
95
96       LC_COLLATE
97                 Determine the locale for the behavior of ranges,  equivalence
98                 classes,  and  multi-character collating elements used in the
99                 extended regular expression defined for  the  yesexpr  locale
100                 keyword in the LC_MESSAGES category.
101
102       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
103                 bytes of text data as characters (for example, single-byte as
104                 opposed  to multi-byte characters in arguments), the behavior
105                 of character classes used in the extended regular  expression
106                 defined  for  the  yesexpr  locale keyword in the LC_MESSAGES
107                 category.
108
109       LC_MESSAGES
110                 Determine the locale used to process  affirmative  responses,
111                 and  the  locale  used  to  affect the format and contents of
112                 diagnostic messages, prompts, and  the  output  from  the  −v
113                 option written to standard error.
114
115       NLSPATH   Determine the location of message catalogs for the processing
116                 of LC_MESSAGES.
117

ASYNCHRONOUS EVENTS

119       Default.
120

STDOUT

122       If no file operands are specified, or if a file operand is '−',  or  if
123       the −c option is specified, the standard output contains the compressed
124       output.
125

STDERR

127       The standard error shall be used only for diagnostic  and  prompt  mes‐
128       sages and the output from −v.
129

OUTPUT FILES

131       The  output  files  shall  contain the compressed output. The format of
132       compressed files is unspecified and interchange of such  files  between
133       implementations  (including  access via unspecified file sharing mecha‐
134       nisms) is not required by POSIX.1‐2008.
135

EXTENDED DESCRIPTION

137       None.
138

EXIT STATUS

140       The following exit values shall be returned:
141
142        0    Successful completion.
143
144        1    An error occurred.
145
146        2    One or more files were not compressed  because  they  would  have
147             increased in size (and the −f option was not specified).
148
149       >2    An error occurred.
150

CONSEQUENCES OF ERRORS

152       The input file shall remain unmodified.
153
154       The following sections are informative.
155

APPLICATION USAGE

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

EXAMPLES

179       None.
180

RATIONALE

182       None.
183

FUTURE DIRECTIONS

185       None.
186

SEE ALSO

188       uncompress, zcat
189
190       The Base Definitions volume of  POSIX.1‐2008,  Chapter  8,  Environment
191       Variables, Section 12.2, Utility Syntax Guidelines
192
194       Portions  of  this text are reprinted and reproduced in electronic form
195       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
196       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
197       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
198       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
199       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
200       event of any discrepancy between this version and the original IEEE and
201       The Open Group Standard, the original IEEE and The Open Group  Standard
202       is  the  referee document. The original Standard can be obtained online
203       at http://www.unix.org/online.html .
204
205       Any typographical or formatting errors that appear  in  this  page  are
206       most likely to have been introduced during the conversion of the source
207       files to man page format. To report such errors,  see  https://www.ker
208       nel.org/doc/man-pages/reporting_bugs.html .
209
210
211
212IEEE/The Open Group                  2013                         COMPRESS(1P)
Impressum