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