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