1GZIP(1)                     General Commands Manual                    GZIP(1)
2
3
4

NAME

6       gzip, gunzip, zcat - compress or expand files
7

SYNOPSIS

9       gzip [ -acdfhklLnNrtvV19 ] [-S suffix] [ name ...  ]
10       gunzip [ -acfhklLnNrtvV ] [-S suffix] [ name ...  ]
11       zcat [ -fhLV ] [ name ...  ]
12

DESCRIPTION

14       The  gzip  command reduces the size of the named files using Lempel-Ziv
15       coding (LZ77).  Whenever possible, each file is replaced  by  one  with
16       the  extension  .gz, while keeping the same ownership modes, access and
17       modification times.  (The default extension is z for MSDOS,  OS/2  FAT,
18       Windows  NT  FAT  and  Atari.)  If no files are specified, or if a file
19       name is "-", the standard input is compressed to the  standard  output.
20       The  gzip command will only attempt to compress regular files.  In par‐
21       ticular, it will ignore symbolic links.
22
23       If the compressed file name is too long for its file system, gzip trun‐
24       cates  it.  The gzip command attempts to truncate only the parts of the
25       file name longer than 3 characters.  (A part is delimited by dots.)  If
26       the name consists of small parts only, the longest parts are truncated.
27       For example, if file names are limited to 14 characters, gzip.msdos.exe
28       is  compressed  to  gzi.msd.exe.gz.  Names are not truncated on systems
29       which do not have a limit on file name length.
30
31       By default, gzip keeps the original file name and timestamp in the com‐
32       pressed  file.  These  are used when decompressing the file with the -N
33       option. This is useful when the compressed file name was  truncated  or
34       when the timestamp was not preserved after a file transfer.
35
36       Compressed  files  can be restored to their original form using gzip -d
37       or gunzip or zcat.  If the original name saved in the  compressed  file
38       is not suitable for its file system, a new name is constructed from the
39       original one to make it legal.
40
41       gunzip takes a list of files on its command line and replaces each file
42       whose  name ends with .gz, -gz, .z, -z, or _z (ignoring case) and which
43       begins with the correct magic number with an uncompressed file  without
44       the  original extension.  gunzip also recognizes the special extensions
45       .tgz and .taz as shorthands for .tar.gz and .tar.Z respectively.   When
46       compressing, gzip uses the .tgz extension if necessary instead of trun‐
47       cating a file with a .tar extension.
48
49       gunzip can currently decompress files created by gzip,  zip,  compress,
50       compress  -H  or pack.  The detection of the input format is automatic.
51       When using the first two formats, gunzip checks a 32 bit CRC. For  pack
52       and gunzip checks the uncompressed length. The standard compress format
53       was not designed to allow consistency checks. However gunzip  is  some‐
54       times  able  to  detect  a bad .Z file. If you get an error when uncom‐
55       pressing a .Z file, do not assume that the .Z file  is  correct  simply
56       because the standard uncompress does not complain. This generally means
57       that the standard uncompress does not check its input, and happily gen‐
58       erates  garbage  output.   The  SCO compress -H format (lzh compression
59       method) does not include a CRC but also allows some consistency checks.
60
61       Files created by zip can be uncompressed by gzip only if  they  have  a
62       single  member  compressed with the 'deflation' method. This feature is
63       only intended to help conversion of tar.zip files to the tar.gz format.
64       To  extract a zip file with a single member, use a command like 'gunzip
65       <foo.zip' or 'gunzip -S .zip foo.zip'.  To extract zip files with  sev‐
66       eral members, use unzip instead of gunzip.
67
68       The zcat command is identical to gunzip -c.  (On some systems, zcat may
69       be installed as gzcat to preserve the original link to compress.)  zcat
70       uncompresses either a list of files on the command line or its standard
71       input and writes the uncompressed data on standard output.   zcat  will
72       uncompress files that have the correct magic number whether they have a
73       .gz suffix or not.
74
75       The gzip command uses the Lempel-Ziv algorithm used in zip  and  PKZIP.
76       The amount of compression obtained depends on the size of the input and
77       the distribution of common substrings.  Typically, text such as  source
78       code  or  English  is reduced by 60-70%.  Compression is generally much
79       better than that achieved by LZW (as used in compress), Huffman  coding
80       (as used in pack), or adaptive Huffman coding (compact).
81
82       Compression  is  always  performed,  even  if  the  compressed  file is
83       slightly larger than the original. The worst case expansion  is  a  few
84       bytes for the gzip file header, plus 5 bytes every 32K block, or an ex‐
85       pansion ratio of 0.015% for large files. Note that the actual number of
86       used disk blocks almost never increases.  gzip preserves the mode, own‐
87       ership and timestamps of files when compressing or decompressing.
88

OPTIONS

90       -a --ascii
91              Ascii text mode: convert end-of-lines using  local  conventions.
92              This  option is supported only on some non-Unix systems. For MS‐
93              DOS, CR LF is converted to LF when compressing, and LF  is  con‐
94              verted to CR LF when decompressing.
95
96       -c --stdout --to-stdout
97              Write  output on standard output; keep original files unchanged.
98              If there are several input files, the output consists of  a  se‐
99              quence  of  independently  compressed  members. To obtain better
100              compression, concatenate  all  input  files  before  compressing
101              them.
102
103       -d --decompress --uncompress
104              Decompress.
105
106       -f --force
107              Force compression or decompression even if the file has multiple
108              links or the corresponding file already exists, or if  the  com‐
109              pressed data is read from or written to a terminal. If the input
110              data is not in a format recognized by gzip, and  if  the  option
111              --stdout  is  also  given, copy the input data without change to
112              the standard output: let zcat behave  as  cat.   If  -f  is  not
113              given,  and  when not running in the background, gzip prompts to
114              verify whether an existing file should be overwritten.
115
116       -h --help
117              Display a help screen and quit.
118
119       -k --keep
120              Keep (don't delete) input files during compression or decompres‐
121              sion.
122
123       -l --list
124              For each compressed file, list the following fields:
125
126                  compressed size: size of the compressed file
127                  uncompressed size: size of the uncompressed file
128                  ratio: compression ratio (0.0% if unknown)
129                  uncompressed_name: name of the uncompressed file
130
131              The  uncompressed size is given as -1 for files not in gzip for‐
132              mat, such as compressed .Z files. To get the  uncompressed  size
133              for such a file, you can use:
134
135                  zcat file.Z | wc -c
136
137              In  combination  with the --verbose option, the following fields
138              are also displayed:
139
140                  method: compression method
141                  crc: the 32-bit CRC of the uncompressed data
142                  date & time: timestamp for the uncompressed file
143
144              The compression methods currently supported  are  deflate,  com‐
145              press,  lzh  (SCO  compress  -H)  and pack.  The crc is given as
146              ffffffff for a file not in gzip format.
147
148              With --name, the uncompressed name,  date and  time   are  those
149              stored within the compress file if present.
150
151              With  --verbose,  the  size totals and compression ratio for all
152              files is also displayed, unless some  sizes  are  unknown.  With
153              --quiet, the title and totals lines are not displayed.
154
155       -L --license
156              Display the gzip license and quit.
157
158       -n --no-name
159              When  compressing,  do not save the original file name and time‐
160              stamp by default. (The original name is always saved if the name
161              had  to  be  truncated.)  When decompressing, do not restore the
162              original file name if present (remove only the gzip suffix  from
163              the  compressed file name) and do not restore the original time‐
164              stamp if present (copy it from the compressed file). This option
165              is the default when decompressing.
166
167       -N --name
168              When  compressing,  always save the original file name and time‐
169              stamp; this is the  default.  When  decompressing,  restore  the
170              original file name and timestamp if present. This option is use‐
171              ful on systems which have a limit on file name  length  or  when
172              the timestamp has been lost after a file transfer.
173
174       -q --quiet
175              Suppress all warnings.
176
177       -r --recursive
178              Travel  the  directory structure recursively. If any of the file
179              names specified on the command line are directories,  gzip  will
180              descend  into  the directory and compress all the files it finds
181              there (or decompress them in the case of gunzip ).
182
183       -S .suf --suffix .suf
184              When compressing, use suffix .suf instead of .gz.  Any non-empty
185              suffix  can  be given, but suffixes other than .z and .gz should
186              be avoided to avoid confusion  when  files  are  transferred  to
187              other systems.
188
189              When  decompressing,  add  .suf  to the beginning of the list of
190              suffixes to try, when deriving an output file name from an input
191              file name.
192
193       --synchronous
194              Use  synchronous  output.  With this option, gzip is less likely
195              to lose data during a system crash, but it can  be  considerably
196              slower.
197
198       -t --test
199              Test. Check the compressed file integrity then quit.
200
201       -v --verbose
202              Verbose. Display the name and percentage reduction for each file
203              compressed or decompressed.
204
205       -V --version
206              Version. Display the version number and compilation options then
207              quit.
208
209       -# --fast --best
210              Regulate  the  speed of compression using the specified digit #,
211              where -1 or --fast  indicates  the  fastest  compression  method
212              (less  compression)  and -9 or --best indicates the slowest com‐
213              pression method (best  compression).   The  default  compression
214              level is -6 (that is, biased towards high compression at expense
215              of speed).
216
217       --rsyncable
218              When you synchronize a compressed file  between  two  computers,
219              this  option  allows  rsync  to  transfer  only  files that were
220              changed in the archive instead of the entire archive.  Normally,
221              after  a change is made to any file in the archive, the compres‐
222              sion algorithm can generate a new version of  the  archive  that
223              does  not  match  the  previous  version of the archive. In this
224              case, rsync transfers the entire new version of the  archive  to
225              the  remote computer.  With this option, rsync can transfer only
226              the changed files as well as a small amount of metadata that  is
227              required  to  update  the archive structure in the area that was
228              changed.
229

ADVANCED USAGE

231       Multiple compressed files can be concatenated.  In  this  case,  gunzip
232       will extract all members at once. For example:
233
234             gzip -c file1  > foo.gz
235             gzip -c file2 >> foo.gz
236
237       Then
238
239             gunzip -c foo
240
241       is equivalent to
242
243             cat file1 file2
244
245       In  case of damage to one member of a .gz file, other members can still
246       be recovered (if the damaged member is removed). However, you  can  get
247       better compression by compressing all members at once:
248
249             cat file1 file2 | gzip > foo.gz
250
251       compresses better than
252
253             gzip -c file1 file2 > foo.gz
254
255       If you want to recompress concatenated files to get better compression,
256       do:
257
258             gzip -cd old.gz | gzip > new.gz
259
260       If a compressed file consists of several members, the uncompressed size
261       and  CRC reported by the --list option applies to the last member only.
262       If you need the uncompressed size for all members, you can use:
263
264             gzip -cd file.gz | wc -c
265
266       If you wish to create a single archive file with  multiple  members  so
267       that members can later be extracted independently, use an archiver such
268       as tar or zip. GNU tar supports the -z option to invoke gzip  transpar‐
269       ently. gzip is designed as a complement to tar, not as a replacement.
270

ENVIRONMENT

272       The obsolescent environment variable GZIP can hold a set of default op‐
273       tions for gzip.  These options are interpreted first and can  be  over‐
274       written  by  explicit command line parameters.  As this can cause prob‐
275       lems when using scripts, this feature is  supported  only  for  options
276       that  are  reasonably likely to not cause too much harm, and gzip warns
277       if it is used.  This feature will be removed in  a  future  release  of
278       gzip.
279
280       You can use an alias or script instead.  For example, if gzip is in the
281       directory /usr/bin you can prepend $HOME/bin to your PATH and create an
282       executable script $HOME/bin/gzip containing the following:
283
284             #! /bin/sh
285             export PATH=/usr/bin
286             exec gzip -9 "$@"
287

SEE ALSO

289       znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), zip(1), unzip(1), com‐
290       press(1)
291
292       The gzip file format is specified in P. Deutsch, GZIP file format spec‐
293       ification version 4.3, <https://www.ietf.org/rfc/rfc1952.txt>, Internet
294       RFC 1952 (May 1996).  The zip  deflation  format  is  specified  in  P.
295       Deutsch,  DEFLATE  Compressed  Data  Format  Specification version 1.3,
296       <https://www.ietf.org/rfc/rfc1951.txt>, Internet RFC 1951 (May 1996).
297

DIAGNOSTICS

299       Exit status is normally 0; if an error occurs, exit status is 1.  If  a
300       warning occurs, exit status is 2.
301
302       Usage: gzip [-cdfhklLnNrtvV19] [-S suffix] [file ...]
303              Invalid options were specified on the command line.
304
305       file: not in gzip format
306              The file specified to gunzip has not been compressed.
307
308       file: Corrupt input. Use zcat to recover some data.
309              The  compressed  file has been damaged. The data up to the point
310              of failure can be recovered using
311
312                    zcat file > recover
313
314       file: compressed with xx bits, can only handle yy bits
315              File was compressed (using LZW) by a  program  that  could  deal
316              with more bits than the decompress code on this machine.  Recom‐
317              press the file with gzip, which compresses better and uses  less
318              memory.
319
320       file: already has .gz suffix -- unchanged
321              The  file  is assumed to be already compressed.  Rename the file
322              and try again.
323
324       file already exists; do you wish to overwrite (y or n)?
325              Respond "y" if you want the output file to be replaced;  "n"  if
326              not.
327
328       gunzip: corrupt input
329              A  SIGSEGV  violation  was detected which usually means that the
330              input file has been corrupted.
331
332       xx.x% Percentage of the input saved by compression.
333              (Relevant only for -v and -l.)
334
335       -- not a regular file or directory: ignored
336              When the input file is not a regular file or directory, (e.g.  a
337              symbolic link, socket, FIFO, device file), it is left unaltered.
338
339       -- has xx other links: unchanged
340              The  input  file has links; it is left unchanged.  See ln(1) for
341              more information. Use the -f flag to force compression of multi‐
342              ply-linked files.
343

CAVEATS

345       When  writing  compressed  data to a tape, it is generally necessary to
346       pad the output with zeroes up to a block boundary.  When  the  data  is
347       read  and the whole block is passed to gunzip for decompression, gunzip
348       detects that there is extra trailing garbage after the compressed  data
349       and emits a warning by default.  You can use the --quiet option to sup‐
350       press the warning.
351

BUGS

353       The gzip format represents the input size modulo 2^32,  so  the  --list
354       option  reports incorrect uncompressed sizes and compression ratios for
355       uncompressed files 4 GB and larger.  To work around this  problem,  you
356       can  use  the following command to discover a large uncompressed file's
357       true size:
358
359             zcat file.gz | wc -c
360
361       The --list option reports sizes as -1 and crc as ffffffff if  the  com‐
362       pressed file is on a non seekable media.
363
364       In  some rare cases, the --best option gives worse compression than the
365       default compression level (-6). On some highly  redundant  files,  com‐
366       press compresses better than gzip.
367

REPORTING BUGS

369       Report bugs to: bug-gzip@gnu.org
370       GNU gzip home page: <https://www.gnu.org/software/gzip/>
371       General help using GNU software: <https://www.gnu.org/gethelp/>
372
374       Copyright © 1998-1999, 2001-2002, 2012, 2015-2021 Free Software Founda‐
375       tion, Inc.
376       Copyright © 1992, 1993 Jean-loup Gailly
377
378       Permission is granted to make and distribute verbatim  copies  of  this
379       manual  provided  the  copyright  notice and this permission notice are
380       preserved on all copies.
381
382       Permission is granted to copy and distribute modified versions of  this
383       manual under the conditions for verbatim copying, provided that the en‐
384       tire resulting derived work is distributed under the terms of a permis‐
385       sion notice identical to this one.
386
387       Permission  is granted to copy and distribute translations of this man‐
388       ual into another language, under the above conditions for modified ver‐
389       sions,  except  that this permission notice may be stated in a transla‐
390       tion approved by the Foundation.
391
392
393
394                                     local                             GZIP(1)
Impressum