Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / gnu / usr.bin / gzip / gzip.1
1 .\" $FreeBSD: src/gnu/usr.bin/gzip/gzip.1,v 1.7 1999/09/20 09:15:15 phantom Exp $
2 .\" $DragonFly: src/gnu/usr.bin/gzip/Attic/gzip.1,v 1.2 2003/06/17 04:25:46 dillon Exp $
3 .\"
4 .PU
5 .TH GZIP 1
6 .SH NAME
7 gzip, gunzip, zcat \- compress or expand files
8 .SH SYNOPSIS
9 .ll +8
10 .B gzip
11 .RB [ " \-acdfhlLnNrtvV19 " ]
12 .RB [ \-S\ suffix ]
13 [
14 .I "name \&..."
15 ]
16 .ll -8
17 .br
18 .B gunzip
19 .RB [ " \-acfhlLnNrtvV " ]
20 .RB [ \-S\ suffix ]
21 [
22 .I "name \&..."
23 ]
24 .br
25 .B zcat
26 .RB [ " \-fhLV " ]
27 [
28 .I "name \&..."
29 ]
30 .SH DESCRIPTION
31 .I Gzip
32 reduces the size of the named files using Lempel-Ziv coding (LZ77).
33 Whenever possible,
34 each file is replaced by one with the extension
35 .B "\&.gz,"
36 while keeping the same ownership modes, access and modification times.
37 (The default extension is
38 .B "\-gz"
39 for VMS,
40 .B "z"
41 for MSDOS, OS/2 FAT, Windows NT FAT and Atari.)
42 If no files are specified, or if a file name is "-", the standard input is
43 compressed to the standard output.
44 .I Gzip
45 will only attempt to compress regular files.
46 In particular, it will ignore symbolic links.
47 .PP
48 If the compressed file name is too long for its file system,
49 .I gzip
50 truncates it.
51 .I Gzip
52 attempts to truncate only the parts of the file name longer than 3 characters.
53 (A part is delimited by dots.) If the name consists of small parts only,
54 the longest parts are truncated. For example, if file names are limited
55 to 14 characters, gzip.msdos.exe is compressed to gzi.msd.exe.gz.
56 Names are not truncated on systems which do not have a limit on file name
57 length.
58 .PP
59 By default,
60 .I gzip
61 keeps the original file name and timestamp in the compressed file. These
62 are used when decompressing the file with the
63 .B \-N
64 option. This is useful when the compressed file name was truncated or
65 when the time stamp was not preserved after a file transfer.
66 .PP
67 Compressed files can be restored to their original form using
68 .I gzip -d
69 or
70 .I gunzip
71 or
72 .I zcat.
73 If the original name saved in the compressed file is not suitable for its
74 file system, a new name is constructed from the original one to make it
75 legal.
76 .PP
77 .I gunzip
78 takes a list of files on its command line and replaces each
79 file whose name ends with .gz, -gz, .z, -z, _z or .Z
80 and which begins with the correct magic number with an uncompressed
81 file without the original extension.
82 .I gunzip
83 also recognizes the special extensions
84 .B "\&.tgz"
85 and
86 .B "\&.taz"
87 as shorthands for
88 .B "\&.tar.gz"
89 and
90 .B "\&.tar.Z"
91 respectively.
92 When compressing,
93 .I gzip
94 uses the
95 .B "\&.tgz"
96 extension if necessary instead of truncating a file with a
97 .B "\&.tar"
98 extension.
99 .PP
100 .I gunzip
101 can currently decompress files created by
102 .I gzip, zip, compress, compress -H
103 or
104 .I pack.
105 The detection of the input format is automatic.  When using
106 the first two formats,
107 .I gunzip
108 checks a 32 bit CRC. For
109 .I pack, gunzip
110 checks the uncompressed length. The standard
111 .I compress
112 format was not designed to allow consistency checks. However
113 .I gunzip
114 is sometimes able to detect a bad .Z file. If you get an error
115 when uncompressing a .Z file, do not assume that the .Z file is
116 correct simply because the standard
117 .I uncompress
118 does not complain. This generally means that the standard
119 .I uncompress
120 does not check its input, and happily generates garbage output.
121 The SCO compress -H format (lzh compression method) does not include a CRC
122 but also allows some consistency checks.
123 .PP
124 Files created by
125 .I zip
126 can be uncompressed by gzip only if they have a single member compressed
127 with the 'deflation' method. This feature is only intended to help
128 conversion of tar.zip files to the tar.gz format. To extract zip files
129 with several members, use
130 .I unzip
131 instead of
132 .I gunzip.
133 .PP
134 .I zcat
135 is identical to
136 .I gunzip
137 .B \-c.
138 (On some systems,
139 .I zcat
140 may be installed as
141 .I gzcat
142 to preserve the original link to
143 .I compress.)
144 .I zcat
145 uncompresses either a list of files on the command line or its
146 standard input and writes the uncompressed data on standard output.
147 .I zcat
148 will uncompress files that have the correct magic number whether
149 they have a
150 .B "\&.gz"
151 suffix or not.
152 .PP
153 .I Gzip
154 uses the Lempel-Ziv algorithm used in
155 .I zip
156 and PKZIP.
157 The amount of compression obtained depends on the size of the
158 input and the distribution of common substrings.
159 Typically, text such as source code or English
160 is reduced by 60\-70%.
161 Compression is generally much better than that achieved by
162 LZW (as used in 
163 .IR compress ),
164 Huffman coding (as used in
165 .IR pack ),
166 or adaptive Huffman coding
167 .RI ( compact ).
168 .PP
169 Compression is always performed, even if the compressed file is
170 slightly larger than the original. The worst case expansion is
171 a few bytes for the gzip file header, plus 5 bytes every 32K block,
172 or an expansion ratio of 0.015% for large files. Note that the actual
173 number of used disk blocks almost never increases.
174 .I gzip
175 preserves the mode, ownership and timestamps of files when compressing
176 or decompressing.
177
178 .SH OPTIONS
179 .TP
180 .B \-a --ascii
181 ASCII text mode: convert end-of-lines using local conventions. This option
182 is supported only on some non-Unix systems. For MSDOS, CR LF is converted
183 to LF when compressing, and LF is converted to CR LF when decompressing.
184 .TP
185 .B \-c --stdout --to-stdout
186 Write output on standard output; keep original files unchanged.
187 If there are several input files, the output consists of a sequence of
188 independently compressed members. To obtain better compression,
189 concatenate all input files before compressing them.
190 .TP
191 .B \-d --decompress --uncompress
192 Decompress.
193 .TP
194 .B \-f --force
195 Force compression or decompression even if the file has multiple links
196 or the corresponding file already exists, or if the compressed data
197 is read from or written to a terminal. If the input data is not in
198 a format recognized by
199 .I gzip,
200 and if the option --stdout is also given, copy the input data without change
201 to the standard output: let
202 .I zcat
203 behave as
204 .I cat.
205 If
206 .B \-f
207 is not given,
208 and when not running in the background,
209 .I gzip
210 prompts to verify whether an existing file should be overwritten.
211 .TP
212 .B \-h --help
213 Display a help screen and quit.
214 .TP
215 .B \-l --list
216 For each compressed file, list the following fields:
217
218     compressed size: size of the compressed file
219     uncompressed size: size of the uncompressed file
220     ratio: compression ratio (0.0% if unknown)
221     uncompressed_name: name of the uncompressed file
222
223 The uncompressed size is given as -1 for files not in gzip format,
224 such as compressed .Z files. To get the uncompressed size for such a file,
225 you can use:
226
227     zcat file.Z | wc -c
228
229 In combination with the --verbose option, the following fields are also
230 displayed:
231
232     method: compression method
233     crc: the 32-bit CRC of the uncompressed data
234     date & time: time stamp for the uncompressed file
235
236 The compression methods currently supported are deflate, compress, lzh
237 (SCO compress -H) and pack.  The crc is given as ffffffff for a file
238 not in gzip format.
239
240 With --name, the uncompressed name,  date and time  are
241 those stored within the compress file if present.
242
243 With --verbose, the size totals and compression ratio for all files
244 is also displayed, unless some sizes are unknown. With --quiet,
245 the title and totals lines are not displayed.
246 .TP
247 .B \-L --license
248 Display the
249 .I gzip
250 license and quit.
251 .TP
252 .B \-n --no-name
253 When compressing, do not save the original file name and time stamp by
254 default. (The original name is always saved if the name had to be
255 truncated.) When decompressing, do not restore the original file name
256 if present (remove only the
257 .I gzip
258 suffix from the compressed file name) and do not restore the original
259 time stamp if present (copy it from the compressed file). This option
260 is the default when decompressing.
261 .TP
262 .B \-N --name
263 When compressing, always save the original file name and time stamp; this
264 is the default. When decompressing, restore the original file name and
265 time stamp if present. This option is useful on systems which have
266 a limit on file name length or when the time stamp has been lost after
267 a file transfer.
268 .TP
269 .B \-q --quiet
270 Suppress all warnings.
271 .TP
272 .B \-r --recursive
273 Travel the directory structure recursively. If any of the file names
274 specified on the command line are directories, 
275 .I gzip
276 will descend into the directory and compress all the files it finds there
277 (or decompress them in the case of
278 .I gunzip
279 ).
280 .TP
281 .B \-S .suf   --suffix .suf
282 Use suffix .suf instead of .gz. Any suffix can be given, but suffixes
283 other than .z and .gz should be avoided to avoid confusion when files
284 are transferred to other systems.  A null suffix forces gunzip to  try
285 decompression on all given files regardless of suffix, as in:
286
287     gunzip -S "" *       (*.* for MSDOS)
288
289 Previous versions of gzip used
290 the .z suffix. This was changed to avoid a conflict with
291 .IR pack "(1)".
292 .TP
293 .B \-t --test
294 Test. Check the compressed file integrity.
295 .TP
296 .B \-v --verbose
297 Verbose. Display the name and percentage reduction for each file compressed
298 or decompressed.
299 .TP
300 .B \-V --version
301 Version. Display the version number and compilation options then quit.
302 .TP
303 .B \-# --fast --best
304 Regulate the speed of compression using the specified digit
305 .IR # ,
306 where
307 .B \-1
308 or
309 .B \-\-fast
310 indicates the fastest compression method (less compression)
311 and
312 .B \-9
313 or
314 .B \-\-best
315 indicates the slowest compression method (best compression).
316 The default compression level is
317 .BR \-6
318 (that is, biased towards high compression at expense of speed).
319 .SH "ADVANCED USAGE"
320 Multiple compressed files can be concatenated. In this case,
321 .I gunzip
322 will extract all members at once. For example:
323
324       gzip -c file1  > foo.gz
325       gzip -c file2 >> foo.gz
326
327 Then
328       gunzip -c foo
329
330 is equivalent to
331
332       cat file1 file2
333
334 In case of damage to one member of a .gz file, other members can
335 still be recovered (if the damaged member is removed). However,
336 you can get better compression by compressing all members at once:
337
338       cat file1 file2 | gzip > foo.gz
339
340 compresses better than
341
342       gzip -c file1 file2 > foo.gz
343
344 If you want to recompress concatenated files to get better compression, do:
345
346       gzip -cd old.gz | gzip > new.gz
347
348 If a compressed file consists of several members, the uncompressed
349 size and CRC reported by the --list option applies to the last member
350 only. If you need the uncompressed size for all members, you can use:
351
352       gzip -cd file.gz | wc -c
353
354 If you wish to create a single archive file with multiple members so
355 that members can later be extracted independently, use an archiver
356 such as tar or zip. GNU tar supports the -z option to invoke gzip
357 transparently. gzip is designed as a complement to tar, not as a
358 replacement.
359 .SH "ENVIRONMENT"
360 The environment variable
361 .B GZIP
362 can hold a set of default options for
363 .I gzip.
364 These options are interpreted first and can be overwritten by
365 explicit command line parameters. For example:
366       for sh:    GZIP="-8v --name"; export GZIP
367       for csh:   setenv GZIP "-8v --name"
368       for MSDOS: set GZIP=-8v --name
369
370 On Vax/VMS, the name of the environment variable is GZIP_OPT, to
371 avoid a conflict with the symbol set for invocation of the program.
372 .SH "SEE ALSO"
373 znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), compress(1)
374 .SH "DIAGNOSTICS"
375 Exit status is normally 0;
376 if an error occurs, exit status is 1. If a warning occurs, exit status is 2.
377 .PP
378 Usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]
379 .in +8
380 Invalid options were specified on the command line.
381 .in -8
382 .IR file :
383 not in gzip format
384 .in +8
385 The file specified to
386 .I gunzip
387 has not been compressed.
388 .in -8
389 .IR file:
390 Corrupt input. Use zcat to recover some data.
391 .in +8
392 The compressed file has been damaged. The data up to the point of failure
393 can be recovered using
394 .in +8
395 zcat file > recover
396 .in -16
397 .IR file :
398 compressed with 
399 .I xx
400 bits, can only handle 
401 .I yy
402 bits
403 .in +8
404 .I File
405 was compressed (using LZW) by a program that could deal with
406 more 
407 .I bits
408 than the decompress code on this machine.
409 Recompress the file with gzip, which compresses better and uses
410 less memory.
411 .in -8
412 .IR file :
413 already has .gz suffix -- no change
414 .in +8
415 The file is assumed to be already compressed.
416 Rename the file and try again.
417 .in -8
418 .I file
419 already exists; do you wish to overwrite (y or n)?
420 .in +8
421 Respond "y" if you want the output file to be replaced; "n" if not.
422 .in -8
423 gunzip: corrupt input
424 .in +8
425 A SIGSEGV violation was detected which usually means that the input file has
426 been corrupted.
427 .in -8
428 .I "xx.x%"
429 .in +8
430 Percentage of the input saved by compression.
431 (Relevant only for
432 .BR \-v
433 and
434 .BR \-l \.)
435 .in -8
436 -- not a regular file or directory: ignored
437 .in +8
438 When the input file is not a regular file or directory,
439 (e.g. a symbolic link, socket, FIFO, device file), it is
440 left unaltered.
441 .in -8
442 -- has 
443 .I xx 
444 other links: unchanged
445 .in +8
446 The input file has links; it is left unchanged.  See
447 .IR ln "(1)"
448 for more information. Use the
449 .B \-f
450 flag to force compression of multiply-linked files.
451 .in -8
452 .SH CAVEATS
453 When writing compressed data to a tape, it is generally necessary to
454 pad the output with zeroes up to a block boundary. When the data is
455 read and the whole block is passed to
456 .I gunzip
457 for decompression,
458 .I gunzip
459 detects that there is extra trailing garbage after the compressed data
460 and emits a warning by default. You have to use the --quiet option to
461 suppress the warning. This option can be set in the
462 .B GZIP
463 environment variable as in:
464   for sh:  GZIP="-q"  tar -xfz --block-compress /dev/rst0
465   for csh: (setenv GZIP -q; tar -xfz --block-compr /dev/rst0
466
467 In the above example, gzip is invoked implicitly by the -z option of
468 GNU tar. Make sure that the same block size (-b option of tar) is used
469 for reading and writing compressed data on tapes.  (This example
470 assumes you are using the GNU version of tar.)
471 .SH BUGS
472 The --list option reports incorrect sizes if they exceed 2 gigabytes.
473 The --list option reports sizes as -1 and crc as ffffffff if the
474 compressed file is on a non seekable media.
475
476 In some rare cases, the --best option gives worse compression than
477 the default compression level (-6). On some highly redundant files,
478 .I compress
479 compresses better than
480 .I gzip.