Commit | Line | Data |
---|---|---|
58777538 KB |
1 | .\" Copyright (c) 1986 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" This code is derived from software contributed to Berkeley by | |
5 | .\" James A. Woods, derived from original work by Spencer Thomas | |
6 | .\" and Joseph Orost. | |
7 | .\" | |
8 | .\" Redistribution and use in source and binary forms are permitted | |
9 | .\" provided that the above copyright notice and this paragraph are | |
10 | .\" duplicated in all such forms and that any documentation, | |
11 | .\" advertising materials, and other materials related to such | |
12 | .\" distribution and use acknowledge that the software was developed | |
13 | .\" by the University of California, Berkeley. The name of the | |
14 | .\" University may not be used to endorse or promote products derived | |
15 | .\" from this software without specific prior written permission. | |
16 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
17 | .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
18 | .\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
19 | .\" | |
20 | .\" @(#)compress.1 6.6 (Berkeley) %G% | |
12c87604 KM |
21 | .\" |
22 | .TH COMPRESS 1 "" | |
23 | .UC 6 | |
24 | .SH NAME | |
29351f11 | 25 | compress, uncompress, zcat \- compress and expand data |
12c87604 | 26 | .SH SYNOPSIS |
58ad5548 | 27 | .PU |
12c87604 KM |
28 | .ll +8 |
29 | .B compress | |
30 | [ | |
12c87604 KM |
31 | .B \-f |
32 | ] [ | |
29351f11 | 33 | .B \-v |
12c87604 KM |
34 | ] [ |
35 | .B \-c | |
36 | ] [ | |
37 | .B \-b | |
38 | .I bits | |
39 | ] [ | |
29351f11 | 40 | .I "name \&..." |
12c87604 KM |
41 | ] |
42 | .ll -8 | |
43 | .br | |
44 | .B uncompress | |
45 | [ | |
46 | .B \-f | |
47 | ] [ | |
29351f11 | 48 | .B \-v |
12c87604 KM |
49 | ] [ |
50 | .B \-c | |
51 | ] [ | |
29351f11 | 52 | .I "name \&..." |
12c87604 KM |
53 | ] |
54 | .br | |
55 | .B zcat | |
56 | [ | |
29351f11 | 57 | .I "name \&..." |
12c87604 KM |
58 | ] |
59 | .SH DESCRIPTION | |
29351f11 KM |
60 | .I Compress |
61 | reduces the size of the named files using adaptive Lempel-Ziv coding. | |
62 | Whenever possible, | |
63 | each file is replaced by one with the extension | |
12c87604 | 64 | .B "\&.Z," |
29351f11 KM |
65 | while keeping the same ownership modes, access and modification times. |
66 | If no files are specified, the standard input is compressed to the | |
67 | standard output. | |
68 | Compressed files can be restored to their original form using | |
12c87604 | 69 | .I uncompress |
29351f11 KM |
70 | or |
71 | .I zcat. | |
12c87604 | 72 | .PP |
29351f11 | 73 | The |
12c87604 | 74 | .B \-f |
29351f11 | 75 | option will force compression of |
b1c071ae JL |
76 | .IR name , |
77 | even if it does not actually shrink | |
78 | or the corresponding | |
79 | .IR name .Z | |
80 | file already exists. | |
81 | Except when run in the background under | |
82 | .IR /bin/sh , | |
83 | if | |
12c87604 | 84 | .B \-f |
b1c071ae JL |
85 | is not given the user is prompted as to whether an existing |
86 | .IR name .Z | |
87 | file should be overwritten. | |
12c87604 KM |
88 | .PP |
89 | The | |
90 | .B \-c | |
06b3e56e | 91 | (``cat'') option makes |
29351f11 KM |
92 | .I compress/uncompress |
93 | write to the standard output; no files are changed. | |
94 | The nondestructive behavior of | |
12c87604 | 95 | .I zcat |
29351f11 | 96 | is identical to that of |
12c87604 | 97 | .I uncompress |
29351f11 | 98 | .B \-c. |
12c87604 KM |
99 | .PP |
100 | .I Compress | |
29351f11 | 101 | uses the modified Lempel-Ziv algorithm popularized in |
12c87604 KM |
102 | "A Technique for High Performance Data Compression", |
103 | Terry A. Welch, | |
29351f11 KM |
104 | .I "IEEE Computer," |
105 | vol. 17, no. 6 (June 1984), pp. 8-19. | |
12c87604 KM |
106 | Common substrings in the file are first replaced by 9-bit codes 257 and up. |
107 | When code 512 is reached, the algorithm switches to 10-bit codes and | |
108 | continues to use more bits until the | |
29351f11 | 109 | limit specified by the |
12c87604 KM |
110 | .B \-b |
111 | flag is reached (default 16). | |
112 | .I Bits | |
113 | must be between 9 and 16. The default can be changed in the source to allow | |
114 | .I compress | |
115 | to be run on a smaller machine. | |
116 | .PP | |
117 | After the | |
118 | .I bits | |
29351f11 | 119 | limit is attained, |
12c87604 KM |
120 | .I compress |
121 | periodically checks the compression ratio. If it is increasing, | |
122 | .I compress | |
123 | continues to use the existing code dictionary. However, | |
124 | if the compression ratio decreases, | |
125 | .I compress | |
126 | discards the table of substrings and rebuilds it from scratch. This allows | |
127 | the algorithm to adapt to the next "block" of the file. | |
128 | .PP | |
29351f11 | 129 | Note that the |
12c87604 | 130 | .B \-b |
29351f11 KM |
131 | flag is omitted for |
132 | .I uncompress, | |
133 | since the | |
134 | .I bits | |
135 | parameter specified during compression | |
136 | is encoded within the output, along with | |
137 | a magic number to ensure that neither decompression of random data nor | |
138 | recompression of compressed data is attempted. | |
12c87604 KM |
139 | .PP |
140 | .ne 8 | |
141 | The amount of compression obtained depends on the size of the | |
29351f11 | 142 | input, the number of |
12c87604 | 143 | .I bits |
29351f11 KM |
144 | per code, and the distribution of common substrings. |
145 | Typically, text such as source code or English | |
146 | is reduced by 50\-60%. | |
12c87604 KM |
147 | Compression is generally much better than that achieved by |
148 | Huffman coding (as used in | |
149 | .IR pack ), | |
150 | or adaptive Huffman coding | |
151 | .RI ( compact ), | |
152 | and takes less time to compute. | |
153 | .PP | |
b1c071ae | 154 | The |
29351f11 | 155 | .B \-v |
b1c071ae JL |
156 | option causes |
157 | the printing of the percentage reduction of each file. | |
12c87604 | 158 | .PP |
b1c071ae JL |
159 | If an error occurs, exit status is 1, else |
160 | if the last file was not compressed because it became larger, the status | |
161 | is 2; else the status is 0. | |
12c87604 | 162 | .SH "DIAGNOSTICS" |
06b3e56e | 163 | Usage: compress [\-fvc] [\-b maxbits] [file ...] |
12c87604 KM |
164 | .in +8 |
165 | Invalid options were specified on the command line. | |
166 | .in -8 | |
167 | Missing maxbits | |
168 | .in +8 | |
169 | Maxbits must follow | |
170 | .BR \-b \. | |
171 | .in -8 | |
12c87604 KM |
172 | .IR file : |
173 | not in compressed format | |
174 | .in +8 | |
29351f11 KM |
175 | The file specified to |
176 | .I uncompress | |
177 | has not been compressed. | |
12c87604 KM |
178 | .in -8 |
179 | .IR file : | |
180 | compressed with | |
181 | .I xx | |
182 | bits, can only handle | |
183 | .I yy | |
184 | bits | |
185 | .in +8 | |
29351f11 KM |
186 | .I File |
187 | was compressed by a program that could deal with | |
12c87604 KM |
188 | more |
189 | .I bits | |
29351f11 KM |
190 | than the compress code on this machine. |
191 | Recompress the file with smaller | |
12c87604 KM |
192 | .IR bits \. |
193 | .in -8 | |
194 | .IR file : | |
195 | already has .Z suffix -- no change | |
196 | .in +8 | |
29351f11 KM |
197 | The file is assumed to be already compressed. |
198 | Rename the file and try again. | |
12c87604 KM |
199 | .in -8 |
200 | .IR file : | |
201 | filename too long to tack on .Z | |
202 | .in +8 | |
29351f11 | 203 | The file cannot be compressed because its name is longer than |
12c87604 | 204 | 12 characters. |
29351f11 KM |
205 | Rename and try again. |
206 | This message does not occur on BSD systems. | |
12c87604 KM |
207 | .in -8 |
208 | .I file | |
209 | already exists; do you wish to overwrite (y or n)? | |
210 | .in +8 | |
211 | Respond "y" if you want the output file to be replaced; "n" if not. | |
212 | .in -8 | |
06b3e56e JL |
213 | uncompress: corrupt input |
214 | .in +8 | |
215 | A SIGSEGV violation was detected which usually means that the input file is | |
216 | corrupted. | |
217 | .in -8 | |
12c87604 KM |
218 | Compression: |
219 | .I "xx.xx%" | |
220 | .in +8 | |
29351f11 KM |
221 | Percentage of the input saved by compression. |
222 | (Relevant only for | |
223 | .BR \-v \.) | |
12c87604 KM |
224 | .in -8 |
225 | -- not a regular file: unchanged | |
226 | .in +8 | |
29351f11 KM |
227 | When the input file is not a regular file, |
228 | (e.g. a directory), it is | |
229 | left unaltered. | |
12c87604 KM |
230 | .in -8 |
231 | -- has | |
232 | .I xx | |
233 | other links: unchanged | |
234 | .in +8 | |
29351f11 | 235 | The input file has links; it is left unchanged. See |
12c87604 KM |
236 | .IR ln "(1)" |
237 | for more information. | |
238 | .in -8 | |
239 | -- file unchanged | |
240 | .in +8 | |
29351f11 KM |
241 | No savings is achieved by |
242 | compression. The input remains virgin. | |
12c87604 | 243 | .in -8 |
29351f11 | 244 | .SH "BUGS" |
06b3e56e | 245 | Although compressed files are compatible between machines with large memory, |
29351f11 KM |
246 | .BR \-b \12 |
247 | should be used for file transfer to architectures with | |
248 | a small process data space (64KB or less, as exhibited by the DEC PDP | |
249 | series, the Intel 80286, etc.) | |
b1c071ae JL |
250 | .PP |
251 | .I compress | |
252 | should be more flexible about the existence of the `.Z' suffix. |