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