summaryrefslogtreecommitdiff
path: root/Build/source/utils/gzip/gzip_2.html
blob: 197bc4ffc7f2507064b419aea8c9b1a74f01a4a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from gzip.texi on 9 August 2001 -->

<TITLE>Gzip User's Manual - 1. Overview</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="gzip_1.html">first</A>, <A HREF="gzip_1.html">previous</A>, <A HREF="gzip_3.html">next</A>, <A HREF="gzip_9.html">last</A> section, <A HREF="gzip_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC4" HREF="gzip_toc.html#TOC4">1. Overview</A></H1>
<P>
<A NAME="IDX1"></A>


<P>
<CODE>gzip</CODE> reduces the size of the named files using Lempel-Ziv coding
(LZ77).  Whenever possible, each file is replaced by one with the
extension <SAMP>`.gz'</SAMP>, while keeping the same ownership modes, access and
modification times.  (The default extension is <SAMP>`-gz'</SAMP> for VMS,
<SAMP>`z'</SAMP> for MSDOS, OS/2 FAT and Atari.)  If no files are specified or
if a file name is "-", the standard input is compressed to the standard
output. <CODE>gzip</CODE> will only attempt to compress regular files.  In
particular, it will ignore symbolic links.


<P>
If the new file name is too long for its file system, <CODE>gzip</CODE>
truncates it.  <CODE>gzip</CODE> 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, <CODE>gzip</CODE> keeps the original file name and timestamp in
the compressed file. These are used when decompressing the file with the
<SAMP>`-N'</SAMP> option. This is useful when the compressed file name was
truncated or when the time stamp was not preserved after a file
transfer.


<P>
Compressed files can be restored to their original form using <SAMP>`gzip -d'</SAMP>
or <CODE>gunzip</CODE> or <CODE>zcat</CODE>.  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>
<CODE>gunzip</CODE> takes a list of files on its command line and replaces
each file whose name ends with <SAMP>`.gz'</SAMP>, <SAMP>`.z'</SAMP>, <SAMP>`.Z'</SAMP>,
<SAMP>`-gz'</SAMP>, <SAMP>`-z'</SAMP> or <SAMP>`_z'</SAMP> and which begins with the correct
magic number with an uncompressed file without the original extension.
<CODE>gunzip</CODE> also recognizes the special extensions <SAMP>`.tgz'</SAMP> and
<SAMP>`.taz'</SAMP> as shorthands for <SAMP>`.tar.gz'</SAMP> and <SAMP>`.tar.Z'</SAMP>
respectively. When compressing, <CODE>gzip</CODE> uses the <SAMP>`.tgz'</SAMP>
extension if necessary instead of truncating a file with a <SAMP>`.tar'</SAMP>
extension.


<P>
<CODE>gunzip</CODE> can currently decompress files created by <CODE>gzip</CODE>,
<CODE>zip</CODE>, <CODE>compress</CODE> or <CODE>pack</CODE>. The detection of the input
format is automatic.  When using the first two formats, <CODE>gunzip</CODE>
checks a 32 bit CRC (cyclic redundancy check). For <CODE>pack</CODE>,
<CODE>gunzip</CODE> checks the uncompressed length. The <CODE>compress</CODE> format
was not designed to allow consistency checks. However <CODE>gunzip</CODE> is
sometimes able to detect a bad <SAMP>`.Z'</SAMP> file. If you get an error when
uncompressing a <SAMP>`.Z'</SAMP> file, do not assume that the <SAMP>`.Z'</SAMP> file is
correct simply because the standard <CODE>uncompress</CODE> does not complain.
This generally means that the standard <CODE>uncompress</CODE> does not check
its input, and happily generates garbage output.  The SCO <SAMP>`compress
-H'</SAMP> format (<CODE>lzh</CODE> compression method) does not include a CRC but
also allows some consistency checks.


<P>
Files created by <CODE>zip</CODE> can be uncompressed by <CODE>gzip</CODE> only if
they have a single member compressed with the 'deflation' method. This
feature is only intended to help conversion of <CODE>tar.zip</CODE> files to
the <CODE>tar.gz</CODE> format. To extract <CODE>zip</CODE> files with several
members, use <CODE>unzip</CODE> instead of <CODE>gunzip</CODE>.


<P>
<CODE>zcat</CODE> is identical to <SAMP>`gunzip -c'</SAMP>.  <CODE>zcat</CODE>
uncompresses either a list of files on the command line or its standard
input and writes the uncompressed data on standard output.  <CODE>zcat</CODE>
will uncompress files that have the correct magic number whether they
have a <SAMP>`.gz'</SAMP> suffix or not.


<P>
<CODE>gzip</CODE> uses the Lempel-Ziv algorithm used in <CODE>zip</CODE> 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 <CODE>compress</CODE>), Huffman
coding (as used in <CODE>pack</CODE>), or adaptive Huffman coding
(<CODE>compact</CODE>).


<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 <CODE>gzip</CODE> 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. <CODE>gzip</CODE> preserves the mode,
ownership and timestamps of files when compressing or decompressing.


<P><HR><P>
Go to the <A HREF="gzip_1.html">first</A>, <A HREF="gzip_1.html">previous</A>, <A HREF="gzip_3.html">next</A>, <A HREF="gzip_9.html">last</A> section, <A HREF="gzip_toc.html">table of contents</A>.
</BODY>
</HTML>