New upstream version 1.8
[debian/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 [ " \-acdfhklLnNrtvV19 " ]
8 .RB [ \-S\ suffix ]
9 [
10 .I "name \&..."
11 ]
12 .ll -8
13 .br
14 .B gunzip
15 .RB [ " \-acfhklLnNrtvV " ]
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 .BR "\&.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 .IR 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, or _z (ignoring case)
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 .IR gzip ,
99 .IR zip ,
100 .IR compress ,
101 .I "compress -H"
102 or
103 .IR pack .
104 The detection of the input format is automatic.  When using
105 the first two formats,
106 .I gunzip
107 checks a 32 bit CRC. For
108 .I pack
109 and
110 .I gunzip
111 checks the uncompressed length. The standard
112 .I compress
113 format was not designed to allow consistency checks. However
114 .I gunzip
115 is sometimes able to detect a bad .Z file. If you get an error
116 when uncompressing a .Z file, do not assume that the .Z file is
117 correct simply because the standard
118 .I uncompress
119 does not complain. This generally means that the standard
120 .I uncompress
121 does not check its input, and happily generates garbage output.
122 The SCO compress -H format (lzh compression method) does not include a CRC
123 but also allows some consistency checks.
124 .PP
125 Files created by
126 .I zip
127 can be uncompressed by gzip only if they have a single member compressed
128 with the 'deflation' method. This feature is only intended to help
129 conversion of tar.zip files to the tar.gz format.  To extract a
130 .I zip
131 file with a single member, use a command like
132 .I "gunzip <foo.zip"
133 or
134 .IR "gunzip -S .zip foo.zip" .
135 To extract zip files
136 with several members, use
137 .I unzip
138 instead of
139 .IR gunzip .
140 .PP
141 .I zcat
142 is identical to
143 .I gunzip
144 .BR \-c .
145 (On some systems,
146 .I zcat
147 may be installed as
148 .I gzcat
149 to preserve the original link to
150 .IR compress .)
151 .I zcat
152 uncompresses either a list of files on the command line or its
153 standard input and writes the uncompressed data on standard output.
154 .I zcat
155 will uncompress files that have the correct magic number whether
156 they have a
157 .B "\&.gz"
158 suffix or not.
159 .PP
160 .I Gzip
161 uses the Lempel-Ziv algorithm used in
162 .I zip
163 and PKZIP.
164 The amount of compression obtained depends on the size of the
165 input and the distribution of common substrings.
166 Typically, text such as source code or English
167 is reduced by 60\-70%.
168 Compression is generally much better than that achieved by
169 LZW (as used in
170 .IR compress ),
171 Huffman coding (as used in
172 .IR pack ),
173 or adaptive Huffman coding
174 .RI ( compact ).
175 .PP
176 Compression is always performed, even if the compressed file is
177 slightly larger than the original. The worst case expansion is
178 a few bytes for the gzip file header, plus 5 bytes every 32K block,
179 or an expansion ratio of 0.015% for large files. Note that the actual
180 number of used disk blocks almost never increases.
181 .I gzip
182 preserves the mode, ownership and timestamps of files when compressing
183 or decompressing.
184 .SH OPTIONS
185 .TP
186 .B \-a --ascii
187 Ascii text mode: convert end-of-lines using local conventions. This option
188 is supported only on some non-Unix systems. For MSDOS, CR LF is converted
189 to LF when compressing, and LF is converted to CR LF when decompressing.
190 .TP
191 .B \-c --stdout --to-stdout
192 Write output on standard output; keep original files unchanged.
193 If there are several input files, the output consists of a sequence of
194 independently compressed members. To obtain better compression,
195 concatenate all input files before compressing them.
196 .TP
197 .B \-d --decompress --uncompress
198 Decompress.
199 .TP
200 .B \-f --force
201 Force compression or decompression even if the file has multiple links
202 or the corresponding file already exists, or if the compressed data
203 is read from or written to a terminal. If the input data is not in
204 a format recognized by
205 .IR gzip ,
206 and if the option --stdout is also given, copy the input data without change
207 to the standard output: let
208 .I zcat
209 behave as
210 .IR cat .
211 If
212 .B \-f
213 is not given,
214 and when not running in the background,
215 .I gzip
216 prompts to verify whether an existing file should be overwritten.
217 .TP
218 .B \-h --help
219 Display a help screen and quit.
220 .TP
221 .B \-k --keep
222 Keep (don't delete) input files during compression or decompression.
223 .TP
224 .B \-l --list
225 For each compressed file, list the following fields:
226
227     compressed size: size of the compressed file
228     uncompressed size: size of the uncompressed file
229     ratio: compression ratio (0.0% if unknown)
230     uncompressed_name: name of the uncompressed file
231
232 The uncompressed size is given as -1 for files not in gzip format,
233 such as compressed .Z files. To get the uncompressed size for such a file,
234 you can use:
235
236     zcat file.Z | wc -c
237
238 In combination with the --verbose option, the following fields are also
239 displayed:
240
241     method: compression method
242     crc: the 32-bit CRC of the uncompressed data
243     date & time: time stamp for the uncompressed file
244
245 The compression methods currently supported are deflate, compress, lzh
246 (SCO compress -H) and pack.  The crc is given as ffffffff for a file
247 not in gzip format.
248
249 With --name, the uncompressed name,  date and time  are
250 those stored within the compress file if present.
251
252 With --verbose, the size totals and compression ratio for all files
253 is also displayed, unless some sizes are unknown. With --quiet,
254 the title and totals lines are not displayed.
255 .TP
256 .B \-L --license
257 Display the
258 .I gzip
259 license and quit.
260 .TP
261 .B \-n --no-name
262 When compressing, do not save the original file name and time stamp by
263 default. (The original name is always saved if the name had to be
264 truncated.) When decompressing, do not restore the original file name
265 if present (remove only the
266 .I gzip
267 suffix from the compressed file name) and do not restore the original
268 time stamp if present (copy it from the compressed file). This option
269 is the default when decompressing.
270 .TP
271 .B \-N --name
272 When compressing, always save the original file name and time stamp; this
273 is the default. When decompressing, restore the original file name and
274 time stamp if present. This option is useful on systems which have
275 a limit on file name length or when the time stamp has been lost after
276 a file transfer.
277 .TP
278 .B \-q --quiet
279 Suppress all warnings.
280 .TP
281 .B \-r --recursive
282 Travel the directory structure recursively. If any of the file names
283 specified on the command line are directories,
284 .I gzip
285 will descend into the directory and compress all the files it finds there
286 (or decompress them in the case of
287 .I gunzip
288 ).
289 .TP
290 .B \-S .suf   --suffix .suf
291 When compressing, use suffix .suf instead of .gz.
292 Any non-empty suffix can be given, but suffixes
293 other than .z and .gz should be avoided to avoid confusion when files
294 are transferred to other systems.
295
296 When decompressing, add .suf to the beginning of the list of
297 suffixes to try, when deriving an output file name from an input file name.
298 .TP
299 .B --synchronous
300 Use synchronous output.  With this option,
301 .I gzip
302 is less likely to lose data during a system crash, but it can be
303 considerably slower.
304 .TP
305 .B \-t --test
306 Test. Check the compressed file integrity.
307 .TP
308 .B \-v --verbose
309 Verbose. Display the name and percentage reduction for each file compressed
310 or decompressed.
311 .TP
312 .B \-V --version
313 Version. Display the version number and compilation options then quit.
314 .TP
315 .B \-# --fast --best
316 Regulate the speed of compression using the specified digit
317 .IR # ,
318 where
319 .B \-1
320 or
321 .B \-\-fast
322 indicates the fastest compression method (less compression)
323 and
324 .B \-9
325 or
326 .B \-\-best
327 indicates the slowest compression method (best compression).
328 The default compression level is
329 .BR \-6
330 (that is, biased towards high compression at expense of speed).
331 .TP
332 .B \-\-rsyncable
333 When you synchronize a compressed file between two computers, this option allows rsync to transfer only files that were changed in the archive instead of the entire archive.
334 Normally, after a change is made to any file in the archive, the compression algorithm can generate a new version of the archive that does not match the previous version of the archive. In this case, rsync transfers the entire new version of the archive to the remote computer.
335 With this option, rsync can transfer only the changed files as well as a small amount of metadata that is required to update the archive structure in the area that was changed.
336 .SH "ADVANCED USAGE"
337 Multiple compressed files can be concatenated. In this case,
338 .I gunzip
339 will extract all members at once. For example:
340
341       gzip -c file1  > foo.gz
342       gzip -c file2 >> foo.gz
343
344 Then
345
346       gunzip -c foo
347
348 is equivalent to
349
350       cat file1 file2
351
352 In case of damage to one member of a .gz file, other members can
353 still be recovered (if the damaged member is removed). However,
354 you can get better compression by compressing all members at once:
355
356       cat file1 file2 | gzip > foo.gz
357
358 compresses better than
359
360       gzip -c file1 file2 > foo.gz
361
362 If you want to recompress concatenated files to get better compression, do:
363
364       gzip -cd old.gz | gzip > new.gz
365
366 If a compressed file consists of several members, the uncompressed
367 size and CRC reported by the --list option applies to the last member
368 only. If you need the uncompressed size for all members, you can use:
369
370       gzip -cd file.gz | wc -c
371
372 If you wish to create a single archive file with multiple members so
373 that members can later be extracted independently, use an archiver
374 such as tar or zip. GNU tar supports the -z option to invoke gzip
375 transparently. gzip is designed as a complement to tar, not as a
376 replacement.
377 .SH "ENVIRONMENT"
378 The obsolescent environment variable
379 .B GZIP
380 can hold a set of default options for
381 .IR gzip .
382 These options are interpreted first and can be overwritten by explicit
383 command line parameters.  As this can cause problems when using
384 scripts, this feature is supported only for options that are
385 reasonably likely to not cause too much harm, and
386 .I gzip
387 warns if it is used.
388 This feature will be removed in a future release of
389 .IR gzip .
390 .PP
391 You can use an alias or script instead.  For example, if
392 .I gzip
393 is in the directory
394 .B /usr/bin
395 you can prepend
396 .B $HOME/bin
397 to your
398 .B PATH
399 and create an executable script
400 .B $HOME/bin/gzip
401 containing the following:
402
403       #! /bin/sh
404       export PATH=/usr/bin
405       exec gzip \-9 "$@"
406
407 On VMS, the name of the obsolescent environment variable is GZIP_OPT, to
408 avoid a conflict with the symbol set for invocation of the program.
409 .SH "SEE ALSO"
410 znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), zip(1), unzip(1), compress(1)
411 .PP
412 The
413 .I gzip
414 file format is specified in P. Deutsch, \s-1GZIP\s0 file format
415 specification version 4.3,
416 .BR <http://www.ietf.org/rfc/rfc1952.txt> ,
417 Internet RFC 1952 (May 1996).
418 The
419 .I zip
420 deflation format is specified in P. Deutsch, \s-1DEFLATE\s0 Compressed
421 Data Format Specification version 1.3,
422 .BR <http://www.ietf.org/rfc/rfc1951.txt> ,
423 Internet RFC 1951 (May 1996).
424 .SH "DIAGNOSTICS"
425 Exit status is normally 0;
426 if an error occurs, exit status is 1. If a warning occurs, exit status is 2.
427 .TP
428 Usage: gzip [-cdfhklLnNrtvV19] [-S suffix] [file ...]
429 Invalid options were specified on the command line.
430 .TP
431 \fIfile\fP\^: not in gzip format
432 The file specified to
433 .I gunzip
434 has not been compressed.
435 .TP
436 \fIfile\fP\^: Corrupt input. Use zcat to recover some data.
437 The compressed file has been damaged. The data up to the point of failure
438 can be recovered using
439
440       zcat \fIfile\fP > recover
441 .TP
442 \fIfile\fP\^: compressed with \fIxx\fP bits, can only handle \fIyy\fP bits
443 .I File
444 was compressed (using LZW) by a program that could deal with
445 more
446 .I bits
447 than the decompress code on this machine.
448 Recompress the file with gzip, which compresses better and uses
449 less memory.
450 .TP
451 \fIfile\fP\^: already has .gz suffix -- unchanged
452 The file is assumed to be already compressed.
453 Rename the file and try again.
454 .TP
455 \fIfile\fP already exists; do you wish to overwrite (y or n)?
456 Respond "y" if you want the output file to be replaced; "n" if not.
457 .TP
458 gunzip: corrupt input
459 A SIGSEGV violation was detected which usually means that the input file has
460 been corrupted.
461 .TP
462 \fIxx.x%\fP Percentage of the input saved by compression.
463 (Relevant only for
464 .BR \-v
465 and
466 .BR \-l \.)
467 .TP
468 -- not a regular file or directory: ignored
469 When the input file is not a regular file or directory,
470 (e.g. a symbolic link, socket, FIFO, device file), it is
471 left unaltered.
472 .TP
473 -- has \fIxx\fP other links: unchanged
474 The input file has links; it is left unchanged.  See
475 .IR ln "(1)"
476 for more information. Use the
477 .B \-f
478 flag to force compression of multiply-linked files.
479 .SH CAVEATS
480 When writing compressed data to a tape, it is generally necessary to
481 pad the output with zeroes up to a block boundary. When the data is
482 read and the whole block is passed to
483 .I gunzip
484 for decompression,
485 .I gunzip
486 detects that there is extra trailing garbage after the compressed data
487 and emits a warning by default.  You can use the --quiet option to
488 suppress the warning.
489 .SH BUGS
490 The gzip format represents the input size modulo 2^32, so the
491 --list option reports incorrect uncompressed sizes and compression
492 ratios for uncompressed files 4 GB and larger.  To work around this
493 problem, you can use the following command to discover a large
494 uncompressed file's true size:
495
496       zcat file.gz | wc -c
497
498 The --list option reports sizes as -1 and crc as ffffffff if the
499 compressed file is on a non seekable media.
500
501 In some rare cases, the --best option gives worse compression than
502 the default compression level (-6). On some highly redundant files,
503 .I compress
504 compresses better than
505 .IR gzip .
506 .SH "COPYRIGHT NOTICE"
507 Copyright \(co 1998-1999, 2001-2002, 2012, 2015-2016 Free Software Foundation,
508 Inc.
509 .br
510 Copyright \(co 1992, 1993 Jean-loup Gailly
511 .PP
512 Permission is granted to make and distribute verbatim copies of
513 this manual provided the copyright notice and this permission notice
514 are preserved on all copies.
515 .ig
516 Permission is granted to process this file through troff and print the
517 results, provided the printed document carries copying permission
518 notice identical to this one except for the removal of this paragraph
519 (this paragraph not being relevant to the printed manual).
520 ..
521 .PP
522 Permission is granted to copy and distribute modified versions of this
523 manual under the conditions for verbatim copying, provided that the entire
524 resulting derived work is distributed under the terms of a permission
525 notice identical to this one.
526 .PP
527 Permission is granted to copy and distribute translations of this manual
528 into another language, under the above conditions for modified versions,
529 except that this permission notice may be stated in a translation approved
530 by the Foundation.