Copyright © 1992-1993 Jean-loup Gailly
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
• Copying | How you can copy and share gzip .
| |
1 Overview | Preliminary information. | |
2 Sample Output | Sample output from gzip .
| |
3 Invoking gzip | How to run gzip .
| |
4 Advanced usage | Concatenated files. | |
5 Reporting Bugs | Reporting bugs. | |
Concept Index | Index of concepts. |
Gzip
reduces the size of the named files using Lempel-Ziv coding
(LZ77). Whenever possible, each file is replaced by one with the
extension ".z", while keeping the same ownership modes, access and
modification times. If no files are specified, the standard input is
compressed to the standard output. If the new file name is too long,
gzip
truncates it and keeps the original file name in the
compressed file. gzip
will only attempt to compress regular
files. In particular, it will ignore symbolic links.
Compressed files can be restored to their original form using
"gzip
-d" or gunzip
or zcat
.
gunzip
takes a list of files on its command line and replaces
each file whose name ends with ".z" or ".Z" and which begins with the
correct magic number with an uncompressed file without the original
extension.
gunzip
can currently decompress files created by gzip
,
zip
, compress
or pack
. The detection of the input
format is automatic. When using the first two formats, gunzip
checks a 32 bit CRC (cyclic redundancy check). For pack
,
gunzip
checks the uncompressed length. The compress
format was not designed to allow consistency checks. However gunzip
is sometimes able to detect a bad .Z file. If you get an error
when uncompressing a .Z file, do not assume that the .Z file is
correct simply because the standard uncompress
does not complain.
This generally means that the standard uncompress
does not check its
input, and happily generates garbage output.
Files created by zip
can be uncompressed by gzip
only if
they have a single member compressed with the ’deflation’ method. This
feature is only intended to help conversion of tar.zip
files to
the tar.z
format. To extract zip
files with several
members, use unzip
instead of gunzip
.
zcat
is identical to "gunzip
-c". zcat
uncompresses either a list of files on the command line or its standard
input and writes the uncompressed data on standard output. zcat
will uncompress files that have the correct magic number whether they
have a ".z" suffix or not.
gzip
uses the Lempel-Ziv algorithm used in zip
and PKZIP.
The amount of compression obtained depends on the size of the input and
the distribution of common substrings. Typically, text such as source
code or English is reduced by 60-70%. Compression is generally much
better than that achieved by LZW (as used in compress
), Huffman
coding (as used in pack
), or adaptive Huffman coding
(compact
).
Compression is always performed, even if the compressed file is slightly
larger than the original. The worst case expansion is a few bytes for
the gzip file header, plus 5 bytes every 32K block, or an expansion
ratio of 0.015% for large files. gzip
preserves the mode,
ownership and timestamps of files when compressing or decompressing.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Here are some realistic examples of running gzip
.
This is the output of the command ‘gzip’:
usage: gzip [-cdfhLrv19] [file ...] For more help, type: gzip -h
This is the output of the command ‘gzip -h’:
gzip 1.0.3 (11 Feb 93) usage: gzip [-cdfhLrtvV19] [file ...] -c --stdout write on standard output, keep original files unchanged -d --decompress decompress -f --force force overwrite of output file and compress links -h --help give this help -L --license display software license -r --recurse recurse through directories -t --test test compressed file integrity (implies -d) -v --verbose verbose mode -V --version display version number -1 --fast compress faster -9 --best compress better file... files to (de)compress. If none given, use standard input
This is the output of the command ‘gzip -v gzip.c’:
gzip.c: 69.8% -- replaced with gzip.c.z
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
gzip
The format for running the gzip
program is:
gzip option …
gzip
supports the following options:
Print an informative help message describing the options.
Write output on standard output; keep original files unchanged. If there are several input files, the output consists of a sequence of independently compressed members. To obtain better compression, concatenate all input files before compressing them.
Decompress.
Force compression even if the file has multiple links or the
corresponding .z file already exists. If -f is not given, and when not
running in the background, gzip
prompts to verify whether an
existing .z file should be overwritten.
Display a help screen.
Display the gzip
license.
Travel the directory structure recursively. If any of the file names
specified on the command line are directories, gzip
will descend
into the directory and compress all the files it finds there (or
decompress them in the case of gunzip
).
Test. Check the compressed file integrity.
Verbose. Display the name and percentage reduction for each file compressed.
Version. Display the version number and compilation options.
Regulate the speed of compression using the specified digit #, where -1 or –fast indicates the fastest compression method (less compression) and –best or -9 indicates the slowest compression method (optimal compression). The default compression level is -5.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Multiple compressed files can be concatenated. In this case,
gunzip
will extract all members at once. If one member is
damaged, other members might still be recovered after removal of the
damaged member. Better compression can be usually obtained if all
members are decompressed then recompressed in a single step.
This is an example of concatenating gzip files:
gzip -c file1 > foo.z gzip -c file2 >> foo.z
Then
gunzip -c foo
is equivalent to
cat file1 file2
In case of damage to one member of a .z file, other members can still be recovered (if the damaged member is removed). However, you can get better compression by compressing all members at once:
cat file1 file2 | gzip > foo.z
compresses better than
gzip -c file1 file2 > foo.z
If you want to recompress concatenated files to get better compression, do:
zcat old.z | gzip > new.z
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If you find a bug in gzip
, please send electronic mail to
‘jloup@chorus.fr’ or, if this fails, to
‘bug-gnu-utils@prep.ai.mit.edu’. Include the version number,
which you can find by running ‘gzip -V’. Also include in your
message the hardware and operating system, the compiler used to compile,
a description of the bug behavior, and the input to gzip that triggered
the bug.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Jump to: | B C I O S |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
B | |||
bugs | 5 Reporting Bugs | ||
| |||
C | |||
concatenated files | 4 Advanced usage | ||
| |||
I | |||
invoking | 3 Invoking gzip | ||
| |||
O | |||
options | 3 Invoking gzip | ||
overview | 1 Overview | ||
| |||
S | |||
sample | 2 Sample Output | ||
|
Jump to: | B C I O S |
---|
[Top] | [Contents] | [Index] | [ ? ] |
[Top] | [Contents] | [Index] | [ ? ] |
[Top] | [Contents] | [Index] | [ ? ] |
This document was generated on February 1, 2023 using texi2html 5.0.
The buttons in the navigation panels have the following meaning:
Button | Name | Go to | From 1.2.3 go to |
---|---|---|---|
[ << ] | FastBack | Beginning of this chapter or previous chapter | 1 |
[ < ] | Back | Previous section in reading order | 1.2.2 |
[ Up ] | Up | Up section | 1.2 |
[ > ] | Forward | Next section in reading order | 1.2.4 |
[ >> ] | FastForward | Next chapter | 2 |
[Top] | Top | Cover (top) of document | |
[Contents] | Contents | Table of contents | |
[Index] | Index | Index | |
[ ? ] | About | About (help) |
where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:
This document was generated on February 1, 2023 using texi2html 5.0.