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