.TH gzip "" "" Command
.PC "GNU utility to compress files"
\fBgzip [ \-cdfhLrtvV19 ] [ \fIfile ... \fB]\fR
.PP
.HS
.SH Options:
.IC \fB\-c\fR
Write output to the standard output
.IC \fB\-d\fR
Decompress each
.I file
.IC \fB\-f\fR
Force:
compress a
.I file
even if its has multiple links or the corresponding file already exists
.IC \fB\-h\fR
Help:
display a screenful of information about how to use this command
.IC \fB\-L\fR
Display licensing information
.IC \fB\-q\fR
Suppress all warning messages.
.IC \fB\-r\fR
Recurse:
if a
.I file
is a directory,
attempt to compress all files within it
.IC \fB\-t\fR
Test the integrity of a compressed
.I file
.IC \fB\-v\fR
Give a verbose description of each action
.IC \fB\-V\fR
Print the current version of this command
.IC \fB\-[1\-9]\fR
Regular speed of compression, from
.B 1
to
.BR 9 ,
where
.B 1
performs the fastest compression but most superficial compression, and
.B 9
the slowest but most thorough compression
.HE
.II GNU
The command
.B gzip
is the GNU command that compresses
.I file
named on its command line.
It will only attempt to compress regular files.
.PP
Whenever possible,
.B gzip
replaces each
.I file
with one that has the suffix \fB.gz\fR, while preserving
its ownership and times of last access and last modification.
If the name of
.I file
is longer than 12 characters (which prevents
.B gzip
from attaching the suffix \fB.gz\fR),
.B gzip
truncates it and keeps its original name within the compressed file.
.PP
If its command line names no
.IR file ,
.B gzip
compresses what it reads from from the standard input, and writes it
to the standard output.
.PP
To restore a compressed file,
filter it thorugh the command
.BR gunzip .
.PP
.II "Lempel-Ziv algorithm"
.II "Huffman coding"
.B gzip
uses the Lempel-Ziv algorithm to perform compression.
Under most circumstances,
this algorithm compresses files more tightly than do most other commonly
used techniques, such as the LZW algorithm, Huffman coding,
or adaptive Huffman coding.
The amount of compression obtained depends upon the size of
the input and the distribution of common substrings; in general, it reduces
text by 60% to 70%.
.PP
.B gzip
always compresses its input,
even if the compressed file is slightly larger than the original.
The worst-case expansion is a few bytes for the
.B gzip
file header, plus five bytes for every 32-kilobyte block.
.SH "Command-Line Options"
.B gzip
recognizes the following command-line options:
.IP \fB\-c\fR
Write output to standard output, and do not change the original
.IR file .
If the command line names more than one
.IR file ,
.B gzip
writes to the standard output
a sequence of independently compressed members.
To obtain better compression, concatenate the
.IR file s
before compressing them.
.IP \fB\-d\fR
Decompress each
.IR file .
.IP \fB\-f\fR
force compression or decompression, even if
.I file
has multiple links or the corresponding file already exists.
Without this option, and when not running in the background,
.B gzip
prompts to verify whether it should overwrite an existing file.
.IP \fB\-h\fR
Help:
display a screenful of information on how to run this program.
.IP \fB\-L\fR
Display the
.B gzip
license.
.IP \fB\-q\fR
Suppress all warning messages.
.IP \fB-r\fR
Recurse:
if a
.I file
is a directory, compress or uncompress all files within it.
.IP \fB-t\fR
Test:
check the integrity of a compressed file.
.IP \fB\-v\fR
Verbose:
display the name and percentage reduction for each
.I file
as it is compressed.
.IP \fB-V\fR
Display the version of this command, and the options by which it
was compiled.
.IP \fB1-9\fR
Regulate the speed of compression, on a scale of from
.B 1
to
.BR 9 .
.B 1
performs the fastest but most superficial compression, whereas
.B 9
performs the slowest but most thorough compression.
.B \-fast
is a synonym for
.BR \-1 ,
whereas
.B \-best
is a synonym for
.BR \-9 .
The default compression level is
.BR \-5 .
.SH "Advanced Usage"
You can concatenate multiple compressed files.
In this case,
.B gunzip
extracts all members at once.
For example:
.DM
	gzip -c file1 > foo.gz
	gzip -c file2 >> foo.gz
	gunzip -c foo
.DE
.PP
is equivalent to:
.DM
	cat file1 file2
.DE
.PP
In case of damage to one member of a
.B .gz
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:
.DM
	cat file1 file2 | gzip > foo.gz
.DE
.PP
compresses better than:
.DM
	gzip -c file1 file2 > foo.gz
.DE
.PP
If you want to recompress concatenated files to get better
compression, type:
.DM
	zcat old.gz | gzip > new.gz
.DE
.SH "Environment"
.B gzip
reads the environment variable
.B GZIP
for its default options.
It interprets these options first; you can override them by
setting other options on the
.B gzip
command line.
.SH "See Also"
.Xr "commands," commands
.Xr "compress," compress
.Xr "compression," compressi
.Xr "gunzip," gunzip
.Xr "uncompress," uncompres
.Xr "unpack," unpack
.Xr "zcmp," zcmp
.Xr "zdiff," zdiff
.Xr "zforce," zforce
.Xr "zgrep," zgrep
.Xr "zmore," zmore
.Xr "znew" znew
.SH Diagnostics
If all went well,
.B gzip
returns zero upon exiting.
If an error occurred, it returns one;
if it issued a warning message, it returns two.
.PP
.B gzip
can issue the following warning messages:
.IP "\fBUsage: gzip [-cdfhLrtvV19] [file ...]\fR"
The
.B gzip
command line contained an option that
.B gzip
does not recognize.
.IP "\fIfile\^\fB: already has z suffix -- no change\fR"
.I file
already has the suffix \fB.gz\fR; therefore,
.B gzip
assumes that it already is compressed.
.IP "\fIfile \fBnot a regular file or directory: ignored\fR"
A
.I file
is not a regular file or directory.
.B gzip
does not attempt to compress devices, pipes, or other special files.
.IP "\fIfile \fB has \fIXX\fB other links: unchanged\fR"
.I file
has more than one link.
By default,
.B gzip
does not compress a file that has multiple links.
.SH Notes
.II "Free Software Foundation"
.II copyleft
.B gzip
is released under the conditions of the Free Software Foundation's
``copyleft''.
Full source code is available through the Mark Williams bulletin board.
