1 This is gzip.info, produced by makeinfo version 4.0 from gzip.texi.
3 INFO-DIR-SECTION Utilities
5 * Gzip: (gzip). The gzip command for compressing files.
8 This file documents the the GNU `gzip' command for compressing files.
10 Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
11 Copyright (C) 1992-1993 Jean-loup Gailly
13 Permission is granted to make and distribute verbatim copies of this
14 manual provided the copyright notice and this permission notice are
15 preserved on all copies.
17 Permission is granted to copy and distribute modified versions of
18 this manual under the conditions for verbatim copying, provided that
19 the entire resulting derived work is distributed under the terms of a
20 permission notice identical to this one.
22 Permission is granted to copy and distribute translations of this
23 manual into another language, under the above conditions for modified
24 versions, except that this permission notice may be stated in a
25 translation approved by the Foundation.
28 File: gzip.info, Node: Top, Up: (dir)
30 This file documents the `gzip' command to compress files.
34 * Overview:: Preliminary information.
35 * Sample:: Sample output from `gzip'.
36 * Invoking gzip:: How to run `gzip'.
37 * Advanced usage:: Concatenated files.
38 * Environment:: The `GZIP' environment variable
39 * Tapes:: Using `gzip' on tapes.
40 * Problems:: Reporting bugs.
41 * Concept Index:: Index of concepts.
44 File: gzip.info, Node: Overview, Next: Sample, Up: Top
49 `gzip' reduces the size of the named files using Lempel-Ziv coding
50 (LZ77). Whenever possible, each file is replaced by one with the
51 extension `.gz', while keeping the same ownership modes, access and
52 modification times. (The default extension is `-gz' for VMS, `z' for
53 MSDOS, OS/2 FAT and Atari.) If no files are specified or if a file
54 name is "-", the standard input is compressed to the standard output.
55 `gzip' will only attempt to compress regular files. In particular, it
56 will ignore symbolic links.
58 If the new file name is too long for its file system, `gzip'
59 truncates it. `gzip' attempts to truncate only the parts of the file
60 name longer than 3 characters. (A part is delimited by dots.) If the
61 name consists of small parts only, the longest parts are truncated.
62 For example, if file names are limited to 14 characters, gzip.msdos.exe
63 is compressed to gzi.msd.exe.gz. Names are not truncated on systems
64 which do not have a limit on file name length.
66 By default, `gzip' keeps the original file name and timestamp in the
67 compressed file. These are used when decompressing the file with the
68 `-N' option. This is useful when the compressed file name was truncated
69 or when the time stamp was not preserved after a file transfer.
71 Compressed files can be restored to their original form using `gzip
72 -d' or `gunzip' or `zcat'. If the original name saved in the
73 compressed file is not suitable for its file system, a new name is
74 constructed from the original one to make it legal.
76 `gunzip' takes a list of files on its command line and replaces each
77 file whose name ends with `.gz', `.z', `.Z', `-gz', `-z' or `_z' and
78 which begins with the correct magic number with an uncompressed file
79 without the original extension. `gunzip' also recognizes the special
80 extensions `.tgz' and `.taz' as shorthands for `.tar.gz' and `.tar.Z'
81 respectively. When compressing, `gzip' uses the `.tgz' extension if
82 necessary instead of truncating a file with a `.tar' extension.
84 `gunzip' can currently decompress files created by `gzip', `zip',
85 `compress' or `pack'. The detection of the input format is automatic.
86 When using the first two formats, `gunzip' checks a 32 bit CRC (cyclic
87 redundancy check). For `pack', `gunzip' checks the uncompressed length.
88 The `compress' format was not designed to allow consistency checks.
89 However `gunzip' is sometimes able to detect a bad `.Z' file. If you
90 get an error when uncompressing a `.Z' file, do not assume that the
91 `.Z' file is correct simply because the standard `uncompress' does not
92 complain. This generally means that the standard `uncompress' does not
93 check its input, and happily generates garbage output. The SCO
94 `compress -H' format (`lzh' compression method) does not include a CRC
95 but also allows some consistency checks.
97 Files created by `zip' can be uncompressed by `gzip' only if they
98 have a single member compressed with the 'deflation' method. This
99 feature is only intended to help conversion of `tar.zip' files to the
100 `tar.gz' format. To extract `zip' files with several members, use
101 `unzip' instead of `gunzip'.
103 `zcat' is identical to `gunzip -c'. `zcat' uncompresses either a
104 list of files on the command line or its standard input and writes the
105 uncompressed data on standard output. `zcat' will uncompress files
106 that have the correct magic number whether they have a `.gz' suffix or
109 `gzip' uses the Lempel-Ziv algorithm used in `zip' and PKZIP. The
110 amount of compression obtained depends on the size of the input and the
111 distribution of common substrings. Typically, text such as source code
112 or English is reduced by 60-70%. Compression is generally much better
113 than that achieved by LZW (as used in `compress'), Huffman coding (as
114 used in `pack'), or adaptive Huffman coding (`compact').
116 Compression is always performed, even if the compressed file is
117 slightly larger than the original. The worst case expansion is a few
118 bytes for the `gzip' file header, plus 5 bytes every 32K block, or an
119 expansion ratio of 0.015% for large files. Note that the actual number
120 of used disk blocks almost never increases. `gzip' preserves the mode,
121 ownership and timestamps of files when compressing or decompressing.
123 The `gzip' file format is specified in P. Deutsch, GZIP file format
124 specification version 4.3, Internet RFC 1952
125 (ftp://ftp.isi.edu/in-notes/rfc1952.txt) (May 1996). The `zip'
126 deflation format is specified in P. Deutsch, DEFLATE Compressed Data
127 Format Specification version 1.3, Internet RFC 1951
128 (ftp://ftp.isi.edu/in-notes/rfc1951.txt) (May 1996).
131 File: gzip.info, Node: Sample, Next: Invoking gzip, Prev: Overview, Up: Top
136 Here are some realistic examples of running `gzip'.
138 This is the output of the command `gzip -h':
142 usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]
143 -c --stdout write on standard output, keep original files unchanged
144 -d --decompress decompress
145 -f --force force overwrite of output file and compress links
146 -h --help give this help
147 -l --list list compressed file contents
148 -L --license display software license
149 -n --no-name do not save or restore the original name and time stamp
150 -N --name save or restore the original name and time stamp
151 -q --quiet suppress all warnings
152 -r --recursive operate recursively on directories
153 -S .suf --suffix .suf use suffix .suf on compressed files
154 -t --test test compressed file integrity
155 -v --verbose verbose mode
156 -V --version display version number
157 -1 --fast compress faster
158 -9 --best compress better
159 file... files to (de)compress. If none given, use standard input.
160 Report bugs to <bug-gzip@gnu.org>.
162 This is the output of the command `gzip -v texinfo.tex':
164 texinfo.tex: 69.7% -- replaced with texinfo.tex.gz
166 The following command will find all `gzip' files in the current
167 directory and subdirectories, and extract them in place without
168 destroying the original:
170 find . -name '*.gz' -print | sed 's/^\(.*\)[.]gz$/gunzip < "&" > "\1"/' | sh
173 File: gzip.info, Node: Invoking gzip, Next: Advanced usage, Prev: Sample, Up: Top
178 The format for running the `gzip' program is:
182 `gzip' supports the following options:
187 Write output on standard output; keep original files unchanged.
188 If there are several input files, the output consists of a
189 sequence of independently compressed members. To obtain better
190 compression, concatenate all input files before compressing them.
199 Force compression or decompression even if the file has multiple
200 links or the corresponding file already exists, or if the
201 compressed data is read from or written to a terminal. If the
202 input data is not in a format recognized by `gzip', and if the
203 option `--stdout' is also given, copy the input data without
204 change to the standard output: let `zcat' behave as `cat'. If `-f'
205 is not given, and when not running in the background, `gzip'
206 prompts to verify whether an existing file should be overwritten.
210 Print an informative help message describing the options then quit.
214 For each compressed file, list the following fields:
216 compressed size: size of the compressed file
217 uncompressed size: size of the uncompressed file
218 ratio: compression ratio (0.0% if unknown)
219 uncompressed_name: name of the uncompressed file
221 The uncompressed size is given as `-1' for files not in `gzip'
222 format, such as compressed `.Z' files. To get the uncompressed
223 size for such a file, you can use:
227 In combination with the `--verbose' option, the following fields
230 method: compression method (deflate,compress,lzh,pack)
231 crc: the 32-bit CRC of the uncompressed data
232 date & time: time stamp for the uncompressed file
234 The crc is given as ffffffff for a file not in gzip format.
236 With `--verbose', the size totals and compression ratio for all
237 files is also displayed, unless some sizes are unknown. With
238 `--quiet', the title and totals lines are not displayed.
240 The `gzip' format represents the the input size modulo 2^32, so
241 the uncompressed size and compression ratio are listed incorrectly
242 for uncompressed files 4 GB and larger. To work around this
243 problem, you can use the following command to discover a large
244 uncompressed file's true size:
250 Display the `gzip' license then quit.
254 When compressing, do not save the original file name and time
255 stamp by default. (The original name is always saved if the name
256 had to be truncated.) When decompressing, do not restore the
257 original file name if present (remove only the `gzip' suffix from
258 the compressed file name) and do not restore the original time
259 stamp if present (copy it from the compressed file). This option
260 is the default when decompressing.
264 When compressing, always save the original file name and time
265 stamp; this is the default. When decompressing, restore the
266 original file name and time stamp if present. This option is
267 useful on systems which have a limit on file name length or when
268 the time stamp has been lost after a file transfer.
272 Suppress all warning messages.
276 Travel the directory structure recursively. If any of the file
277 names specified on the command line are directories, `gzip' will
278 descend into the directory and compress all the files it finds
279 there (or decompress them in the case of `gunzip').
283 Use suffix `SUF' instead of `.gz'. Any suffix can be given, but
284 suffixes other than `.z' and `.gz' should be avoided to avoid
285 confusion when files are transferred to other systems. A null
286 suffix forces gunzip to try decompression on all given files
287 regardless of suffix, as in:
289 gunzip -S "" * (*.* for MSDOS)
291 Previous versions of gzip used the `.z' suffix. This was changed to
292 avoid a conflict with `pack'.
296 Test. Check the compressed file integrity.
300 Verbose. Display the name and percentage reduction for each file
305 Version. Display the version number and compilation options, then
311 Regulate the speed of compression using the specified digit N,
312 where `-1' or `--fast' indicates the fastest compression method
313 (less compression) and `--best' or `-9' indicates the slowest
314 compression method (optimal compression). The default compression
315 level is `-6' (that is, biased towards high compression at expense
319 File: gzip.info, Node: Advanced usage, Next: Environment, Prev: Invoking gzip, Up: Top
324 Multiple compressed files can be concatenated. In this case,
325 `gunzip' will extract all members at once. If one member is damaged,
326 other members might still be recovered after removal of the damaged
327 member. Better compression can be usually obtained if all members are
328 decompressed and then recompressed in a single step.
330 This is an example of concatenating `gzip' files:
332 gzip -c file1 > foo.gz
333 gzip -c file2 >> foo.gz
343 In case of damage to one member of a `.gz' file, other members can
344 still be recovered (if the damaged member is removed). However, you can
345 get better compression by compressing all members at once:
347 cat file1 file2 | gzip > foo.gz
349 compresses better than
351 gzip -c file1 file2 > foo.gz
353 If you want to recompress concatenated files to get better
356 zcat old.gz | gzip > new.gz
358 If a compressed file consists of several members, the uncompressed
359 size and CRC reported by the `--list' option applies to the last member
360 only. If you need the uncompressed size for all members, you can use:
364 If you wish to create a single archive file with multiple members so
365 that members can later be extracted independently, use an archiver such
366 as `tar' or `zip'. GNU `tar' supports the `-z' option to invoke `gzip'
367 transparently. `gzip' is designed as a complement to `tar', not as a
371 File: gzip.info, Node: Environment, Next: Tapes, Prev: Advanced usage, Up: Top
376 The environment variable `GZIP' can hold a set of default options for
377 `gzip'. These options are interpreted first and can be overwritten by
378 explicit command line parameters. For example:
380 for sh: GZIP="-8v --name"; export GZIP
381 for csh: setenv GZIP "-8v --name"
382 for MSDOS: set GZIP=-8v --name
384 On Vax/VMS, the name of the environment variable is `GZIP_OPT', to
385 avoid a conflict with the symbol set for invocation of the program.
388 File: gzip.info, Node: Tapes, Next: Problems, Prev: Environment, Up: Top
390 Using `gzip' on tapes
391 *********************
393 When writing compressed data to a tape, it is generally necessary to
394 pad the output with zeroes up to a block boundary. When the data is
395 read and the whole block is passed to `gunzip' for decompression,
396 `gunzip' detects that there is extra trailing garbage after the
397 compressed data and emits a warning by default if the garbage contains
398 nonzero bytes. You have to use the `--quiet' option to suppress the
399 warning. This option can be set in the `GZIP' environment variable, as
402 for sh: GZIP="-q" tar -xfz --block-compress /dev/rst0
403 for csh: (setenv GZIP "-q"; tar -xfz --block-compress /dev/rst0)
405 In the above example, `gzip' is invoked implicitly by the `-z'
406 option of GNU `tar'. Make sure that the same block size (`-b' option
407 of `tar') is used for reading and writing compressed data on tapes.
408 (This example assumes you are using the GNU version of `tar'.)
411 File: gzip.info, Node: Problems, Next: Concept Index, Prev: Tapes, Up: Top
416 If you find a bug in `gzip', please send electronic mail to
417 <bug-gzip@gnu.org>. Include the version number, which you can find by
418 running `gzip -V'. Also include in your message the hardware and
419 operating system, the compiler used to compile `gzip', a description of
420 the bug behavior, and the input to `gzip' that triggered the bug.
423 File: gzip.info, Node: Concept Index, Prev: Problems, Up: Top
431 * concatenated files: Advanced usage.
432 * Environment: Environment.
433 * invoking: Invoking gzip.
434 * options: Invoking gzip.
435 * overview: Overview.
443 Node: Overview
\7f1482
445 Node: Invoking gzip
\7f7789
446 Node: Advanced usage
\7f12770
447 Node: Environment
\7f14359
449 Node: Problems
\7f15941
450 Node: Concept Index
\7f16393