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