]> git.cworth.org Git - gzip/blob - gzip.doc
Imported Upstream version 1.3.2
[gzip] / gzip.doc
1
2 User Commands                                             GZIP(1)
3
4 NAME
5      gzip, gunzip, zcat - compress or expand files
6
7 SYNOPSIS
8      gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ...  ]
9      gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ...  ]
10      zcat [ -fhLV ] [ name ...  ]
11
12 DESCRIPTION
13      Gzip  reduces  the  size of the named files using Lempel-Ziv
14      coding (LZ77).  Whenever possible, each file is replaced  by
15      one with the extension .gz, while keeping the same ownership
16      modes, access and modification times.  (The  default  exten-
17      sion  is  -gz for VMS, z for MSDOS, OS/2 FAT, Windows NT FAT
18      and Atari.)  If no files are specified, or if a file name is
19      "-",  the  standard input is compressed to the standard out-
20      put.  Gzip will only attempt to compress regular files.   In
21      particular, it will ignore symbolic links.
22
23      If the compressed file name is too long for its file system,
24      gzip truncates it.  Gzip attempts to truncate only the parts
25      of  the  file  name  longer  than  3 characters.  (A part is
26      delimited by dots.) If the  name  consists  of  small  parts
27      only,  the longest parts are truncated. For example, if file
28      names are limited to 14 characters, gzip.msdos.exe  is  com-
29      pressed  to gzi.msd.exe.gz.  Names are not truncated on sys-
30      tems which do not have a limit on file name length.
31
32      By default, gzip keeps the original file name and  timestamp
33      in  the  compressed  file. These are used when decompressing
34      the file with the -N option. This is useful  when  the  com-
35      pressed  file  name was truncated or when the time stamp was
36      not preserved after a file transfer.
37
38      Compressed files can be  restored  to  their  original  form
39      using gzip -d or gunzip or zcat.  If the original name saved
40      in the compressed file is not suitable for its file  system,
41      a  new  name is constructed from the original one to make it
42      legal.
43
44      gunzip takes a  list  of  files  on  its  command  line  and
45      replaces each file whose name ends with .gz, -gz, .z, -z, _z
46      or .Z and which begins with the correct magic number with an
47      uncompressed  file  without  the original extension.  gunzip
48      also recognizes the special  extensions  .tgz  and  .taz  as
49      shorthands  for  .tar.gz and .tar.Z respectively.  When com-
50      pressing, gzip uses the .tgz extension if necessary  instead
51      of truncating a file with a .tar extension.
52
53      gunzip  can currently decompress files created by gzip, zip,
54      compress, compress -H or pack.  The detection of  the  input
55      format  is  automatic.   When  using  the first two formats,
56
57 SunOS 5.8               Last change: local                      1
58
59 User Commands                                             GZIP(1)
60
61      gunzip checks a 32 bit CRC.  For  pack,  gunzip  checks  the
62      uncompressed  length.  The  standard compress format was not
63      designed to allow  consistency  checks.  However  gunzip  is
64      sometimes  able to detect a bad .Z file. If you get an error
65      when uncompressing a .Z file, do not assume that the .Z file
66      is  correct  simply because the standard uncompress does not
67      complain. This generally means that the standard  uncompress
68      does not check its input, and happily generates garbage out-
69      put.  The SCO compress -H format  (lzh  compression  method)
70      does  not  include  a  CRC  but also allows some consistency
71      checks.
72
73      Files created by zip can be uncompressed  by  gzip  only  if
74      they  have  a  single member compressed with the 'deflation'
75      method. This feature is only intended to help conversion  of
76      tar.zip  files  to  the  tar.gz format. To extract zip files
77      with several members, use unzip instead of gunzip.
78
79      zcat is identical to gunzip -c.  (On some systems, zcat  may
80      be  installed as gzcat to preserve the original link to com-
81      press.)  zcat uncompresses either a list  of  files  on  the
82      command  line  or  its  standard input and writes the uncom-
83      pressed data on standard output.  zcat will uncompress files
84      that  have  the correct magic number whether they have a .gz
85      suffix or not.
86
87      Gzip uses the Lempel-Ziv algorithm used in  zip  and  PKZIP.
88      The  amount  of  compression obtained depends on the size of
89      the input and the distribution of common substrings.   Typi-
90      cally,  text  such  as  source code or English is reduced by
91      60-70%.  Compression is  generally  much  better  than  that
92      achieved  by  LZW  (as used in compress), Huffman coding (as
93      used in pack), or adaptive Huffman coding (compact).
94
95      Compression is always performed, even if the compressed file
96      is  slightly larger than the original. The worst case expan-
97      sion is a few bytes for the gzip file header, plus  5  bytes
98      every  32K  block, or an expansion ratio of 0.015% for large
99      files. Note that the  actual  number  of  used  disk  blocks
100      almost  never increases.  gzip preserves the mode, ownership
101      and timestamps of files when compressing or decompressing.
102
103 OPTIONS
104      -a --ascii
105           Ascii text mode: convert end-of-lines using local  con-
106           ventions.  This  option  is supported only on some non-
107           Unix systems. For MSDOS, CR LF is converted to LF  when
108           compressing,  and  LF is converted to CR LF when decom-
109           pressing.
110
111      -c --stdout --to-stdout
112
113 SunOS 5.8               Last change: local                      2
114
115 User Commands                                             GZIP(1)
116
117           Write output on standard output;  keep  original  files
118           unchanged.   If there are several input files, the out-
119           put consists of a sequence of independently  compressed
120           members.  To obtain better compression, concatenate all
121           input files before compressing them.
122
123      -d --decompress --uncompress
124           Decompress.
125
126      -f --force
127           Force compression or decompression even if the file has
128           multiple   links  or  the  corresponding  file  already
129           exists, or if the compressed data is read from or writ-
130           ten to a terminal. If the input data is not in a format
131           recognized by gzip, and if the option --stdout is  also
132           given,  copy the input data without change to the stan-
133           dard ouput: let zcat behave  as  cat.   If  -f  is  not
134           given,  and  when  not  running in the background, gzip
135           prompts to verify whether an existing  file  should  be
136           overwritten.
137
138      -h --help
139           Display a help screen and quit.
140
141      -l --list
142           For each compressed file, list the following fields:
143
144               compressed size: size of the compressed file
145               uncompressed size: size of the uncompressed file
146               ratio: compression ratio (0.0% if unknown)
147               uncompressed_name: name of the uncompressed file
148
149           The  uncompressed  size is given as -1 for files not in
150           gzip format, such as compressed .Z files.  To  get  the
151           uncompressed size for such a file, you can use:
152
153               zcat file.Z | wc -c
154
155           In combination with the --verbose option, the following
156           fields are also displayed:
157
158               method: compression method
159               crc: the 32-bit CRC of the uncompressed data
160               date & time: time stamp for the uncompressed file
161
162           The  compression  methods   currently   supported   are
163           deflate, compress, lzh (SCO compress -H) and pack.  The
164           crc is given as ffffffff for a file not in gzip format.
165
166           With --name, the uncompressed name,  date and time  are
167           those stored within the compress file if present.
168
169 SunOS 5.8               Last change: local                      3
170
171 User Commands                                             GZIP(1)
172
173           With --verbose, the size totals and  compression  ratio
174           for  all files is also displayed, unless some sizes are
175           unknown. With --quiet, the title and totals  lines  are
176           not displayed.
177
178      -L --license
179           Display the gzip license and quit.
180
181      -n --no-name
182           When  compressing,  do  not save the original file name
183           and time stamp by default. (The original name is always
184           saved  if  the  name  had to be truncated.) When decom-
185           pressing, do not restore the original file name if pre-
186           sent  (remove  only the gzip suffix from the compressed
187           file name) and do not restore the original  time  stamp
188           if  present  (copy  it  from the compressed file). This
189           option is the default when decompressing.
190
191      -N --name
192           When compressing, always save the  original  file  name
193           and  time  stamp; this is the default. When decompress-
194           ing, restore the original file name and time  stamp  if
195           present.  This option is useful on systems which have a
196           limit on file name length or when the  time  stamp  has
197           been lost after a file transfer.
198
199      -q --quiet
200           Suppress all warnings.
201
202      -r --recursive
203           Travel  the  directory structure recursively. If any of
204           the file names specified on the command line are direc-
205           tories,  gzip  will descend into the directory and com-
206           press all the files it finds there (or decompress  them
207           in the case of gunzip ).
208
209      -S .suf --suffix .suf
210           Use  suffix  .suf  instead  of  .gz.  Any suffix can be
211           given, but suffixes other than .z  and  .gz  should  be
212           avoided  to  avoid confusion when files are transferred
213           to other systems.  A null suffix forces gunzip to   try
214           decompression  on all given files regardless of suffix,
215           as in:
216
217               gunzip -S "" *       (*.* for MSDOS)
218
219           Previous versions of gzip used the .z suffix. This  was
220           changed to avoid a conflict with pack(1).
221
222      -t --test
223           Test. Check the compressed file integrity.
224
225 SunOS 5.8               Last change: local                      4
226
227 User Commands                                             GZIP(1)
228
229      -v --verbose
230           Verbose.  Display the name and percentage reduction for
231           each file compressed or decompressed.
232
233      -V --version
234           Version. Display the  version  number  and  compilation
235           options then quit.
236
237      -# --fast --best
238           Regulate  the  speed of compression using the specified
239           digit #, where -1 or --fast indicates the fastest  com-
240           pression  method  (less  compression)  and -9 or --best
241           indicates the slowest compression method (best compres-
242           sion).   The  default compression level is -6 (that is,
243           biased towards high compression at expense of speed).
244
245 ADVANCED USAGE
246      Multiple compressed files can be concatenated. In this case,
247      gunzip will extract all members at once. For example:
248
249            gzip -c file1  > foo.gz
250            gzip -c file2 >> foo.gz
251
252      Then
253
254            gunzip -c foo
255
256      is equivalent to
257
258            cat file1 file2
259
260      In case of damage to one member of a .gz file, other members
261      can still be recovered (if the damaged member  is  removed).
262      However,  you  can get better compression by compressing all
263      members at once:
264
265            cat file1 file2 | gzip > foo.gz
266
267      compresses better than
268
269            gzip -c file1 file2 > foo.gz
270
271      If you want to recompress concatenated files to  get  better
272      compression, do:
273
274            gzip -cd old.gz | gzip > new.gz
275
276      If a compressed file consists of several members, the uncom-
277      pressed size and CRC reported by the --list  option  applies
278      to  the  last member only. If you need the uncompressed size
279      for all members, you can use:
280
281 SunOS 5.8               Last change: local                      5
282
283 User Commands                                             GZIP(1)
284
285            gzip -cd file.gz | wc -c
286
287      If you wish to create a single archive  file  with  multiple
288      members  so  that  members  can  later be extracted indepen-
289      dently, use an archiver such as tar or zip. GNU tar supports
290      the -z option to invoke gzip transparently. gzip is designed
291      as a complement to tar, not as a replacement.
292
293 ENVIRONMENT
294      The environment variable GZIP can  hold  a  set  of  default
295      options  for  gzip.  These options are interpreted first and
296      can be overwritten by explicit command line parameters.  For
297      example:
298            for sh:    GZIP="-8v --name"; export GZIP
299            for csh:   setenv GZIP "-8v --name"
300            for MSDOS: set GZIP=-8v --name
301
302      On   Vax/VMS,  the  name  of  the  environment  variable  is
303      GZIP_OPT, to avoid a conflict with the symbol set for  invo-
304      cation of the program.
305
306 SEE ALSO
307      znew(1),  zcmp(1),  zmore(1),  zforce(1),  gzexe(1), zip(1),
308      unzip(1), compress(1), pack(1), compact(1)
309
310      The gzip file format is specified in P. Deutsch,  GZIP  file
311      format  specification  version  4.3,  <ftp://ftp.isi.edu/in-
312      notes/rfc1952.txt>, Internet RFC 1952 (May 1996).   The  zip
313      deflation  format  is  specified in P. Deutsch, DEFLATE Com-
314      pressed   Data    Format    Specification    version    1.3,
315      <ftp://ftp.isi.edu/in-notes/rfc1951.txt>,  Internet RFC 1951
316      (May 1996).
317
318 DIAGNOSTICS
319      Exit status is normally 0; if an error occurs,  exit  status
320      is 1. If a warning occurs, exit status is 2.
321
322      Usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]
323           Invalid options were specified on the command line.
324
325      file: not in gzip format
326           The file specified to gunzip has not been compressed.
327
328      file: Corrupt input. Use zcat to recover some data.
329           The  compressed  file  has been damaged. The data up to
330           the point of failure can be recovered using
331
332                 zcat file > recover
333
334      file: compressed with xx bits, can only handle yy bits
335           File was compressed (using LZW) by a program that could
336           deal  with  more  bits than the decompress code on this
337
338 SunOS 5.8               Last change: local                      6
339
340 User Commands                                             GZIP(1)
341
342           machine.  Recompress the file  with  gzip,  which  com-
343           presses better and uses less memory.
344
345      file: already has .gz suffix -- no change
346           The  file  is assumed to be already compressed.  Rename
347           the file and try again.
348
349      file already exists; do you wish to overwrite (y or n)?
350           Respond "y" if you want the output file to be replaced;
351           "n" if not.
352
353      gunzip: corrupt input
354           A  SIGSEGV  violation  was detected which usually means
355           that the input file has been corrupted.
356
357      xx.x% Percentage of the input saved by compression.
358           (Relevant only for -v and -l.)
359
360      -- not a regular file or directory: ignored
361           When the input file is not a regular file or directory,
362           (e.g.  a  symbolic link, socket, FIFO, device file), it
363           is left unaltered.
364
365      -- has xx other links: unchanged
366           The input file has links; it is  left  unchanged.   See
367           ln(1)  for  more  information. Use the -f flag to force
368           compression of multiply-linked files.
369
370 CAVEATS
371      When writing compressed data to a tape, it is generally nec-
372      essary to pad the output with zeroes up to a block boundary.
373      When the data is read and the whole block is passed to  gun-
374      zip  for  decompression,  gunzip detects that there is extra
375      trailing garbage after the compressed data and emits a warn-
376      ing  by  default. You have to use the --quiet option to sup-
377      press the warning. This option can be set in the GZIP  envi-
378      ronment variable as in:
379        for sh:  GZIP="-q"  tar -xfz --block-compress /dev/rst0
380        for csh: (setenv GZIP -q; tar -xfz --block-compr /dev/rst0
381
382      In the above example, gzip is invoked implicitly by  the  -z
383      option  of  GNU  tar. Make sure that the same block size (-b
384      option of tar) is used for reading  and  writing  compressed
385      data  on tapes.  (This example assumes you are using the GNU
386      version of tar.)
387
388 BUGS
389      The gzip format represents the the input size  modulo  2^32,
390      so  the  --list  option reports incorrect uncompressed sizes
391      and compression ratios  for  uncompressed  files  4  GB  and
392      larger.   To  work around this problem, you can use the fol-
393      lowing command to discover a large uncompressed file's  true
394
395 SunOS 5.8               Last change: local                      7
396
397 User Commands                                             GZIP(1)
398
399      size:
400
401            zcat file.gz | wc -c
402
403      The --list option reports sizes as -1 and crc as ffffffff if
404      the compressed file is on a non seekable media.
405
406      In some rare cases, the --best option gives  worse  compres-
407      sion than the default compression level (-6). On some highly
408      redundant files, compress compresses better than gzip.
409
410 COPYRIGHT NOTICE
411      Copyright (C) 1998, 1999,  2001  Free  Software  Foundation,
412      Inc.
413      Copyright (C) 1992, 1993 Jean-loup Gailly
414
415      Permission is granted to make and distribute verbatim copies
416      of this manual provided the copyright notice and  this  per-
417      mission notice are preserved on all copies.
418
419      Permission  is  granted to copy and distribute modified ver-
420      sions of this manual under the conditions for verbatim copy-
421      ing, provided that the entire resulting derived work is dis-
422      tributed under the terms of a permission notice identical to
423      this one.
424
425      Permission is granted to copy and distribute translations of
426      this manual into another language, under  the  above  condi-
427      tions  for  modified  versions,  except that this permission
428      notice may be stated in a translation approved by the  Foun-
429      dation.
430
431 SunOS 5.8               Last change: local                      8
432