Debian Codegraph @

upstream/fedora-44/man1/compress.1

raw
1 .TH COMPRESS 1 local
2 .SH NAME
3 compress, uncompress, zcat \- compress and expand data
4 .SH SYNOPSIS
5 .ll +8
6 .B compress
7 [
8 .B \-f
9 ] [
10 .B \-k
11 ] [
12 .B \-v
13 ] [
14 .B \-c
15 ] [
16 .B \-V
17 ] [
18 .B \-r
19 ] [
20 .B \-b
21 .I bits
22 ] [
23 .B \-\-
24 ] [
25 .I "name \&..."
26 ]
27 .ll -8
28 .br
29 .B uncompress
30 [
31 .B \-f
32 ] [
33 .B \-k
34 ] [
35 .B \-v
36 ] [
37 .B \-c
38 ] [
39 .B \-V
40 ] [
41 .B \-\-
42 ] [
43 .I "name \&..."
44 ]
45 .br
46 .B zcat
47 [
48 .B \-V
49 ] [
50 .B \-\-
51 ] [
52 .I "name \&..."
53 ]
54 .SH DESCRIPTION
55 .I Compress
56 reduces the size of the named files using adaptive Lempel\-Ziv coding.
57 Whenever possible,
58 each file is replaced by one with the extension
59 .B "\&.Z,"
60 while keeping the same ownership modes, access and modification times.
61 If no files are specified, the standard input is compressed to the
62 standard output.
63 .I Compress
64 will only attempt to compress regular files.
65 In particular, it will ignore symbolic links. If a file has multiple
66 hard links,
67 .I compress
68 will refuse to compress it unless the
69 .B \-f
70 flag is given.
71 .PP
72 If
73 .B \-f
74 is not given and
75 .I compress
76 is run in the foreground,
77 the user is prompted as to whether an existing file should be overwritten.
78 .PP
79 Compressed files can be restored to their original form using
80 .I uncompress
81 or
82 .I zcat.
83 .PP
84 .I uncompress
85 takes a list of files on its command line and replaces each
86 file whose name ends with
87 .B "\&.Z"
88 and which begins with the correct magic number with an uncompressed
89 file without the
90 .B "\&.Z."
91 The uncompressed file will have the mode, ownership and
92 timestamps of the compressed file.
93 .PP
94 The
95 .B \-k
96 option makes
97 .I compress/uncompress
98 keep the input files instead of automatically removing them.
99 .PP
100 The
101 .B \-c
102 option makes
103 .I compress/uncompress
104 write to the standard output; no files are changed.
105 .PP
106 .I zcat
107 is identical to
108 .I uncompress
109 .B \-c.
110 .I zcat
111 uncompresses either a list of files on the command line or its
112 standard input and writes the uncompressed data on standard output.
113 .I zcat
114 will uncompress files that have the correct magic number whether
115 they have a
116 .B "\&.Z"
117 suffix or not.
118 .PP
119 If the
120 .B \-r
121 flag is specified,
122 .I compress
123 will operate recursively. If any of the file names specified on the command
124 line are directories,
125 .I compress
126 will descend into the directory and compress all the files it finds there.
127 When compressing, any files already compressed will be ignored, and when
128 decompressing, any files already decompressed will be ignored.
129 .PP
130 The
131 .B \-V
132 flag tells each of these programs to print its version and patchlevel,
133 along with any preprocessor flags specified during compilation, on
134 stderr before doing any compression or uncompression.
135 .PP
136 .I Compress
137 uses the modified Lempel\-Ziv algorithm popularized in
138 "A Technique for High Performance Data Compression",
139 Terry A. Welch,
140 .I "IEEE Computer,"
141 vol. 17, no. 6 (June 1984), pp. 8\-19.
142 Common substrings in the file are first replaced by 9\-bit codes 257 and up.
143 When code 512 is reached, the algorithm switches to 10\-bit codes and
144 continues to use more bits until the
145 limit specified by the
146 .B \-b
147 flag is reached (default 16).
148 .I Bits
149 must be between 9 and 16. The default can be changed in the source to allow
150 .I compress
151 to be run on a smaller machine.
152 .PP
153 After the
154 .I bits
155 limit is attained,
156 .I compress
157 periodically checks the compression ratio. If it is increasing,
158 .I compress
159 continues to use the existing code dictionary. However,
160 if the compression ratio decreases,
161 .I compress
162 discards the table of substrings and rebuilds it from scratch. This allows
163 the algorithm to adapt to the next "block" of the file.
164 .PP
165 Note that the
166 .B \-b
167 flag is omitted for
168 .I uncompress,
169 since the
170 .I bits
171 parameter specified during compression
172 is encoded within the output, along with
173 a magic number to ensure that neither decompression of random data nor
174 recompression of compressed data is attempted.
175 .PP
176 .ne 8
177 The amount of compression obtained depends on the size of the
178 input, the number of
179 .I bits
180 per code, and the distribution of common substrings.
181 Typically, text such as source code or English
182 is reduced by 50\-60%.
183 Compression is generally much better than that achieved by
184 Huffman coding (as used in
185 .IR pack ),
186 or adaptive Huffman coding
187 .RI ( compact ),
188 and takes less time to compute.
189 .PP
190 Under the
191 .B \-v
192 option,
193 a message is printed yielding the percentage of
194 reduction for each file compressed.
195 .PP
196 .B \-\-
197 may be used to halt option parsing and force all remaining arguments to be
198 treated as paths.
199 .SH "DIAGNOSTICS"
200 Exit status is normally 0;
201 if the last file is larger after (attempted) compression, the status is 2;
202 if an error occurs, exit status is 1.
203 .PP
204 Usage: compress [\-dfvcVr] [\-b maxbits] [file ...]
205 .in +8
206 Invalid options were specified on the command line.
207 .in -8
208 Missing maxbits
209 .in +8
210 Maxbits must follow
211 .BR \-b \.
212 .in -8
213 .IR file :
214 not in compressed format
215 .in +8
216 The file specified to
217 .I uncompress
218 has not been compressed.
219 .in -8
220 .IR file :
221 compressed with
222 .I xx
223 bits, can only handle
224 .I yy
225 bits
226 .in +8
227 .I File
228 was compressed by a program that could deal with
229 more
230 .I bits
231 than the compress code on this machine.
232 Recompress the file with smaller
233 .IR bits \.
234 .in -8
235 .IR file :
236 already has .Z suffix \-\- no change
237 .in +8
238 The file is assumed to be already compressed.
239 Rename the file and try again.
240 .in -8
241 .IR file :
242 filename too long to tack on .Z
243 .in +8
244 The file cannot be compressed because its name is longer than
245 12 characters.
246 Rename and try again.
247 This message does not occur on BSD systems.
248 .in -8
249 .I file
250 already exists; do you wish to overwrite (y or n)?
251 .in +8
252 Respond "y" if you want the output file to be replaced; "n" if not.
253 .in -8
254 uncompress: corrupt input
255 .in +8
256 A SIGSEGV violation was detected which usually means that the input file has
257 been corrupted.
258 .in -8
259 Compression:
260 .I "xx.xx%"
261 .in +8
262 Percentage of the input saved by compression.
263 (Relevant only for
264 .BR \-v \.)
265 .in -8
266 \-\- not a regular file or directory: ignored
267 .in +8
268 When the input file is not a regular file or directory,
269 (e.g. a symbolic link, socket, FIFO, device file), it is
270 left unaltered.
271 .in -8
272 \-\- has
273 .I xx
274 other links: unchanged
275 .in +8
276 The input file has links; it is left unchanged. See
277 .IR ln "(1)"
278 for more information. Use the
279 .B \-f
280 flag to force compression of multiply\-linked files.
281 .in -8
282 \-\- file unchanged
283 .in +8
284 No savings is achieved by
285 compression. The input remains virgin.
286 .in -8
287 .SH "BUGS"
288 Although compressed files are compatible between machines with large memory,
289 .BR \-b \12
290 should be used for file transfer to architectures with
291 a small process data space (64KB or less, as exhibited by the DEC PDP
292 series, the Intel 80286, etc.)
293 .SH "SEE ALSO"
294 .BR pack (1),
295 .BR compact (1)