man-pages/man1/gzip.1.html
2021-03-31 01:06:50 +01:00

710 lines
20 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GZIP</TITLE>
</HEAD><BODY>
<H1>GZIP</H1>
Section: User Commands (1)<BR>Updated: local<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
gzip, gunzip, zcat - compress or expand files
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>gzip</B>
[<B> -acdfhklLnNrtvV19 </B>]
[<B>-S&nbsp;suffix</B>]
[
<I>name ...</I>
]
<BR>
<B>gunzip</B>
[<B> -acfhklLnNrtvV </B>]
[<B>-S&nbsp;suffix</B>]
[
<I>name ...</I>
]
<BR>
<B>zcat</B>
[<B> -fhLV </B>]
[
<I>name ...</I>
]
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<I>Gzip</I>
reduces the size of the named files using Lempel-Ziv coding (LZ77).
Whenever possible,
each file is replaced by one with the extension
<B>.gz</B>,
while keeping the same ownership modes, access and modification times.
(The default extension is
<B>z</B>
for MSDOS, OS/2 FAT, Windows NT FAT and Atari.)
If no files are specified, or if a file name is &quot;-&quot;, the standard input is
compressed to the standard output.
<I>Gzip</I>
will only attempt to compress regular files.
In particular, it will ignore symbolic links.
<P>
If the compressed file name is too long for its file system,
<I>gzip</I>
truncates it.
<I>Gzip</I>
attempts to truncate only the parts of the file name longer than 3 characters.
(A part is delimited by dots.) If the name consists of small parts only,
the longest parts are truncated. For example, if file names are limited
to 14 characters, gzip.msdos.exe is compressed to gzi.msd.exe.gz.
Names are not truncated on systems which do not have a limit on file name
length.
<P>
By default,
<I>gzip</I>
keeps the original file name and timestamp in the compressed file. These
are used when decompressing the file with the
<B>-N</B>
option. This is useful when the compressed file name was truncated or
when the timestamp was not preserved after a file transfer.
<P>
Compressed files can be restored to their original form using
<I>gzip -d</I>
or
<I>gunzip</I>
or
<I>zcat</I>.
If the original name saved in the compressed file is not suitable for its
file system, a new name is constructed from the original one to make it
legal.
<P>
<I>gunzip</I>
takes a list of files on its command line and replaces each
file whose name ends with .gz, -gz, .z, -z, or _z (ignoring case)
and which begins with the correct magic number with an uncompressed
file without the original extension.
<I>gunzip</I>
also recognizes the special extensions
<B>.tgz</B>
and
<B>.taz</B>
as shorthands for
<B>.tar.gz</B>
and
<B>.tar.Z</B>
respectively.
When compressing,
<I>gzip</I>
uses the
<B>.tgz</B>
extension if necessary instead of truncating a file with a
<B>.tar</B>
extension.
<P>
<I>gunzip</I>
can currently decompress files created by
<I>gzip</I>,
<I>zip</I>,
<I>compress</I>,
<I>compress -H</I>
or
<I>pack</I>.
The detection of the input format is automatic. When using
the first two formats,
<I>gunzip</I>
checks a 32 bit CRC. For
<I>pack</I>
and
<I>gunzip</I>
checks the uncompressed length. The standard
<I>compress</I>
format was not designed to allow consistency checks. However
<I>gunzip</I>
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
<I>uncompress</I>
does not complain. This generally means that the standard
<I>uncompress</I>
does not check its input, and happily generates garbage output.
The SCO compress -H format (lzh compression method) does not include a CRC
but also allows some consistency checks.
<P>
Files created by
<I>zip</I>
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.gz format. To extract a
<I>zip</I>
file with a single member, use a command like
<I>gunzip &lt;foo.zip</I>
or
<I>gunzip -S .zip foo.zip</I>.
To extract zip files
with several members, use
<I>unzip</I>
instead of
<I>gunzip</I>.
<P>
<I>zcat</I>
is identical to
<I>gunzip</I>
<B>-c</B>.
(On some systems,
<I>zcat</I>
may be installed as
<I>gzcat</I>
to preserve the original link to
<I>compress</I>.)
<I>zcat</I>
uncompresses either a list of files on the command line or its
standard input and writes the uncompressed data on standard output.
<I>zcat</I>
will uncompress files that have the correct magic number whether
they have a
<B>.gz</B>
suffix or not.
<P>
<I>Gzip</I>
uses the Lempel-Ziv algorithm used in
<I>zip</I>
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
<I>compress</I>),
Huffman coding (as used in
<I>pack</I>),
or adaptive Huffman coding
(<I>compact</I>).
<P>
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. Note that the actual
number of used disk blocks almost never increases.
<I>gzip</I>
preserves the mode, ownership and timestamps of files when compressing
or decompressing.
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
<DL COMPACT>
<DT id="1"><B>-a --ascii</B>
<DD>
Ascii text mode: convert end-of-lines using local conventions. This option
is supported only on some non-Unix systems. For MSDOS, CR LF is converted
to LF when compressing, and LF is converted to CR LF when decompressing.
<DT id="2"><B>-c --stdout --to-stdout</B>
<DD>
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.
<DT id="3"><B>-d --decompress --uncompress</B>
<DD>
Decompress.
<DT id="4"><B>-f --force</B>
<DD>
Force compression or decompression even if the file has multiple links
or the corresponding file already exists, or if the compressed data
is read from or written to a terminal. If the input data is not in
a format recognized by
<I>gzip</I>,
and if the option --stdout is also given, copy the input data without change
to the standard output: let
<I>zcat</I>
behave as
<I>cat</I>.
If
<B>-f</B>
is not given,
and when not running in the background,
<I>gzip</I>
prompts to verify whether an existing file should be overwritten.
<DT id="5"><B>-h --help</B>
<DD>
Display a help screen and quit.
<DT id="6"><B>-k --keep</B>
<DD>
Keep (don't delete) input files during compression or decompression.
<DT id="7"><B>-l --list</B>
<DD>
For each compressed file, list the following fields:
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;compressed&nbsp;size:&nbsp;size&nbsp;of&nbsp;the&nbsp;compressed&nbsp;file
<BR>&nbsp;&nbsp;&nbsp;&nbsp;uncompressed&nbsp;size:&nbsp;size&nbsp;of&nbsp;the&nbsp;uncompressed&nbsp;file
<BR>&nbsp;&nbsp;&nbsp;&nbsp;ratio:&nbsp;compression&nbsp;ratio&nbsp;(0.0%&nbsp;if&nbsp;unknown)
<BR>&nbsp;&nbsp;&nbsp;&nbsp;uncompressed_name:&nbsp;name&nbsp;of&nbsp;the&nbsp;uncompressed&nbsp;file
<P>
The uncompressed size is given as -1 for files not in gzip format,
such as compressed .Z files. To get the uncompressed size for such a file,
you can use:
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;zcat&nbsp;file.Z&nbsp;|&nbsp;wc&nbsp;-c
<P>
In combination with the --verbose option, the following fields are also
displayed:
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;method:&nbsp;compression&nbsp;method
<BR>&nbsp;&nbsp;&nbsp;&nbsp;crc:&nbsp;the&nbsp;32-bit&nbsp;CRC&nbsp;of&nbsp;the&nbsp;uncompressed&nbsp;data
<BR>&nbsp;&nbsp;&nbsp;&nbsp;date&nbsp;&amp;&nbsp;time:&nbsp;timestamp&nbsp;for&nbsp;the&nbsp;uncompressed&nbsp;file
<P>
The compression methods currently supported are deflate, compress, lzh
(SCO compress -H) and pack. The crc is given as ffffffff for a file
not in gzip format.
<P>
With --name, the uncompressed name, date and time are
those stored within the compress file if present.
<P>
With --verbose, the size totals and compression ratio for all files
is also displayed, unless some sizes are unknown. With --quiet,
the title and totals lines are not displayed.
<DT id="8"><B>-L --license</B>
<DD>
Display the
<I>gzip</I>
license and quit.
<DT id="9"><B>-n --no-name</B>
<DD>
When compressing, do not save the original file name and timestamp by
default. (The original name is always saved if the name had to be
truncated.) When decompressing, do not restore the original file name
if present (remove only the
<I>gzip</I>
suffix from the compressed file name) and do not restore the original
timestamp if present (copy it from the compressed file). This option
is the default when decompressing.
<DT id="10"><B>-N --name</B>
<DD>
When compressing, always save the original file name and timestamp; this
is the default. When decompressing, restore the original file name and
timestamp if present. This option is useful on systems which have
a limit on file name length or when the timestamp has been lost after
a file transfer.
<DT id="11"><B>-q --quiet</B>
<DD>
Suppress all warnings.
<DT id="12"><B>-r --recursive</B>
<DD>
Travel the directory structure recursively. If any of the file names
specified on the command line are directories,
<I>gzip</I>
will descend into the directory and compress all the files it finds there
(or decompress them in the case of
<I>gunzip</I>
).
<DT id="13"><B>-S .suf --suffix .suf</B>
<DD>
When compressing, use suffix .suf instead of .gz.
Any non-empty suffix can be given, but suffixes
other than .z and .gz should be avoided to avoid confusion when files
are transferred to other systems.
<P>
When decompressing, add .suf to the beginning of the list of
suffixes to try, when deriving an output file name from an input file name.
<DT id="14"><B>--synchronous</B>
<DD>
Use synchronous output. With this option,
<I>gzip</I>
is less likely to lose data during a system crash, but it can be
considerably slower.
<DT id="15"><B>-t --test</B>
<DD>
Test. Check the compressed file integrity.
<DT id="16"><B>-v --verbose</B>
<DD>
Verbose. Display the name and percentage reduction for each file compressed
or decompressed.
<DT id="17"><B>-V --version</B>
<DD>
Version. Display the version number and compilation options then quit.
<DT id="18"><B>-# --fast --best</B>
<DD>
Regulate the speed of compression using the specified digit
<I>#</I>,
where
<B>-1</B>
or
<B>--fast</B>
indicates the fastest compression method (less compression)
and
<B>-9</B>
or
<B>--best</B>
indicates the slowest compression method (best compression).
The default compression level is
<B>-6</B>
(that is, biased towards high compression at expense of speed).
<DT id="19"><B>--rsyncable</B>
<DD>
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.
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.
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.
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>ADVANCED USAGE</H2>
Multiple compressed files can be concatenated. In this case,
<I>gunzip</I>
will extract all members at once. For example:
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip&nbsp;-c&nbsp;file1&nbsp;&nbsp;&gt;&nbsp;foo.gz
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip&nbsp;-c&nbsp;file2&nbsp;&gt;&gt;&nbsp;foo.gz
<P>
Then
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gunzip&nbsp;-c&nbsp;foo
<P>
is equivalent to
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cat&nbsp;file1&nbsp;file2
<P>
In case of damage to one member of a .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:
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cat&nbsp;file1&nbsp;file2&nbsp;|&nbsp;gzip&nbsp;&gt;&nbsp;foo.gz
<P>
compresses better than
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip&nbsp;-c&nbsp;file1&nbsp;file2&nbsp;&gt;&nbsp;foo.gz
<P>
If you want to recompress concatenated files to get better compression, do:
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip&nbsp;-cd&nbsp;old.gz&nbsp;|&nbsp;gzip&nbsp;&gt;&nbsp;new.gz
<P>
If a compressed file consists of several members, the uncompressed
size and CRC reported by the --list option applies to the last member
only. If you need the uncompressed size for all members, you can use:
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gzip&nbsp;-cd&nbsp;file.gz&nbsp;|&nbsp;wc&nbsp;-c
<P>
If you wish to create a single archive file with multiple members so
that members can later be extracted independently, use an archiver
such as tar or zip. GNU tar supports the -z option to invoke gzip
transparently. gzip is designed as a complement to tar, not as a
replacement.
<A NAME="lbAG">&nbsp;</A>
<H2>ENVIRONMENT</H2>
The obsolescent environment variable
<B>GZIP</B>
can hold a set of default options for
<I>gzip</I>.
These options are interpreted first and can be overwritten by explicit
command line parameters. As this can cause problems when using
scripts, this feature is supported only for options that are
reasonably likely to not cause too much harm, and
<I>gzip</I>
warns if it is used.
This feature will be removed in a future release of
<I>gzip</I>.
<P>
You can use an alias or script instead. For example, if
<I>gzip</I>
is in the directory
<B>/usr/bin</B>
you can prepend
<B>$HOME/bin</B>
to your
<B>PATH</B>
and create an executable script
<B>$HOME/bin/gzip</B>
containing the following:
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#!&nbsp;/bin/sh
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;export&nbsp;PATH=/usr/bin
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exec&nbsp;gzip&nbsp;-9&nbsp;&quot;$@&quot;
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<A HREF="/cgi-bin/man/man2html?1+znew">znew</A>(1), <A HREF="/cgi-bin/man/man2html?1+zcmp">zcmp</A>(1), <A HREF="/cgi-bin/man/man2html?1+zmore">zmore</A>(1), <A HREF="/cgi-bin/man/man2html?1+zforce">zforce</A>(1), <A HREF="/cgi-bin/man/man2html?1+gzexe">gzexe</A>(1), <A HREF="/cgi-bin/man/man2html?1+zip">zip</A>(1), <A HREF="/cgi-bin/man/man2html?1+unzip">unzip</A>(1), <A HREF="/cgi-bin/man/man2html?1+compress">compress</A>(1)
<P>
The
<I>gzip</I>
file format is specified in P. Deutsch, <FONT SIZE="-1">GZIP</FONT> file format
specification version 4.3,
<B>&lt;<A HREF="https://www.ietf.org/rfc/rfc1952.txt">https://www.ietf.org/rfc/rfc1952.txt</A>&gt;</B>,
Internet RFC 1952 (May 1996).
The
<I>zip</I>
deflation format is specified in P. Deutsch, <FONT SIZE="-1">DEFLATE</FONT> Compressed
Data Format Specification version 1.3,
<B>&lt;<A HREF="https://www.ietf.org/rfc/rfc1951.txt">https://www.ietf.org/rfc/rfc1951.txt</A>&gt;</B>,
Internet RFC 1951 (May 1996).
<A NAME="lbAI">&nbsp;</A>
<H2>DIAGNOSTICS</H2>
Exit status is normally 0;
if an error occurs, exit status is 1. If a warning occurs, exit status is 2.
<DL COMPACT>
<DT id="20">Usage: gzip [-cdfhklLnNrtvV19] [-S suffix] [file ...]<DD>
Invalid options were specified on the command line.
<DT id="21"><I>file</I>: not in gzip format<DD>
The file specified to
<I>gunzip</I>
has not been compressed.
<DT id="22"><I>file</I>: Corrupt input. Use zcat to recover some data.<DD>
The compressed file has been damaged. The data up to the point of failure
can be recovered using
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;zcat&nbsp;<I>file</I>&nbsp;&gt;&nbsp;recover
<DT id="23"><I>file</I>: compressed with <I>xx</I> bits, can only handle <I>yy</I> bits<DD>
<I>File</I>
was compressed (using LZW) by a program that could deal with
more
<I>bits</I>
than the decompress code on this machine.
Recompress the file with gzip, which compresses better and uses
less memory.
<DT id="24"><I>file</I>: already has .gz suffix -- unchanged<DD>
The file is assumed to be already compressed.
Rename the file and try again.
<DT id="25"><I>file</I> already exists; do you wish to overwrite (y or n)?<DD>
Respond &quot;y&quot; if you want the output file to be replaced; &quot;n&quot; if not.
<DT id="26">gunzip: corrupt input<DD>
A SIGSEGV violation was detected which usually means that the input file has
been corrupted.
<DT id="27"><I>xx.x%</I> Percentage of the input saved by compression.<DD>
(Relevant only for
<B>-v</B>
and
<B>-l</B>.)
<DT id="28">-- not a regular file or directory: ignored<DD>
When the input file is not a regular file or directory,
(e.g. a symbolic link, socket, FIFO, device file), it is
left unaltered.
<DT id="29">-- has <I>xx</I> other links: unchanged<DD>
The input file has links; it is left unchanged. See
<I><A HREF="/cgi-bin/man/man2html?1+ln">ln</A></I>(1)
for more information. Use the
<B>-f</B>
flag to force compression of multiply-linked files.
</DL>
<A NAME="lbAJ">&nbsp;</A>
<H2>CAVEATS</H2>
When writing compressed data to a tape, it is generally necessary to
pad the output with zeroes up to a block boundary. When the data is
read and the whole block is passed to
<I>gunzip</I>
for decompression,
<I>gunzip</I>
detects that there is extra trailing garbage after the compressed data
and emits a warning by default. You can use the --quiet option to
suppress the warning.
<A NAME="lbAK">&nbsp;</A>
<H2>BUGS</H2>
The gzip format represents the input size modulo 2^32, so the
--list option reports incorrect uncompressed sizes and compression
ratios for uncompressed files 4 GB and larger. To work around this
problem, you can use the following command to discover a large
uncompressed file's true size:
<P>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;zcat&nbsp;file.gz&nbsp;|&nbsp;wc&nbsp;-c
<P>
The --list option reports sizes as -1 and crc as ffffffff if the
compressed file is on a non seekable media.
<P>
In some rare cases, the --best option gives worse compression than
the default compression level (-6). On some highly redundant files,
<I>compress</I>
compresses better than
<I>gzip</I>.
<A NAME="lbAL">&nbsp;</A>
<H2>COPYRIGHT NOTICE</H2>
Copyright &#169; 1998-1999, 2001-2002, 2012, 2015-2018 Free Software Foundation,
Inc.
<BR>
Copyright &#169; 1992, 1993 Jean-loup Gailly
<P>
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.
<P>
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.
<P>
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.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="30"><A HREF="#lbAB">NAME</A><DD>
<DT id="31"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="32"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="33"><A HREF="#lbAE">OPTIONS</A><DD>
<DT id="34"><A HREF="#lbAF">ADVANCED USAGE</A><DD>
<DT id="35"><A HREF="#lbAG">ENVIRONMENT</A><DD>
<DT id="36"><A HREF="#lbAH">SEE ALSO</A><DD>
<DT id="37"><A HREF="#lbAI">DIAGNOSTICS</A><DD>
<DT id="38"><A HREF="#lbAJ">CAVEATS</A><DD>
<DT id="39"><A HREF="#lbAK">BUGS</A><DD>
<DT id="40"><A HREF="#lbAL">COPYRIGHT NOTICE</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:16 GMT, March 31, 2021
</BODY>
</HTML>