5 gzip, gunzip, zcat - compress or expand files
8 gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ]
9 gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ]
10 zcat [ -fhLV ] [ name ... ]
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.
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.
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.
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
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.
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,
57 SunOS 5.8 Last change: local 1
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
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.
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
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).
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.
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
113 SunOS 5.8 Last change: local 2
115 User Commands GZIP(1)
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-
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.
132 -d --decompress --uncompress
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
148 Display a help screen and quit.
151 For each compressed file, list the following fields:
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
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:
164 In combination with the --verbose option, the following
165 fields are also displayed:
167 method: compression method
168 crc: the 32-bit CRC of the uncompressed data
170 SunOS 5.8 Last change: local 3
172 User Commands GZIP(1)
174 date & time: time stamp for the uncompressed file
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.
180 With --name, the uncompressed name, date and time are
181 those stored within the compress file if present.
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
189 Display the gzip license and quit.
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.
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.
210 Suppress all warnings.
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 ).
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,
227 SunOS 5.8 Last change: local 4
229 User Commands GZIP(1)
231 gunzip -S "" * (*.* for MSDOS)
233 Previous versions of gzip used the .z suffix. This was
234 changed to avoid a conflict with pack(1).
237 Test. Check the compressed file integrity.
240 Verbose. Display the name and percentage reduction for
241 each file compressed or decompressed.
244 Version. Display the version number and compilation
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).
256 Multiple compressed files can be concatenated. In this case,
257 gunzip will extract all members at once. For example:
259 gzip -c file1 > foo.gz
260 gzip -c file2 >> foo.gz
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
275 cat file1 file2 | gzip > foo.gz
277 compresses better than
279 gzip -c file1 file2 > foo.gz
281 If you want to recompress concatenated files to get better
284 SunOS 5.8 Last change: local 5
286 User Commands GZIP(1)
288 gzip -cd old.gz | gzip > new.gz
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:
295 gzip -cd file.gz | wc -c
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.
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
308 for sh: GZIP="-8v --name"; export GZIP
309 for csh: setenv GZIP "-8v --name"
310 for MSDOS: set GZIP=-8v --name
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.
317 znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), zip(1),
318 unzip(1), compress(1), pack(1), compact(1)
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
329 Exit status is normally 0; if an error occurs, exit status
330 is 1. If a warning occurs, exit status is 2.
332 Usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]
333 Invalid options were specified on the command line.
335 file: not in gzip format
336 The file specified to gunzip has not been compressed.
338 file: Corrupt input. Use zcat to recover some data.
339 The compressed file has been damaged. The data up to
341 SunOS 5.8 Last change: local 6
343 User Commands GZIP(1)
345 the point of failure can be recovered using
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.
355 file: already has .gz suffix -- no change
356 The file is assumed to be already compressed. Rename
357 the file and try again.
359 file already exists; do you wish to overwrite (y or n)?
360 Respond "y" if you want the output file to be replaced;
363 gunzip: corrupt input
364 A SIGSEGV violation was detected which usually means
365 that the input file has been corrupted.
367 xx.x% Percentage of the input saved by compression.
368 (Relevant only for -v and -l.)
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
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.
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
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
398 SunOS 5.8 Last change: local 7
400 User Commands GZIP(1)
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
412 The --list option reports sizes as -1 and crc as ffffffff if
413 the compressed file is on a non seekable media.
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.
420 Copyright (C) 1998, 1999, 2001, 2002 Free Software Founda-
422 Copyright (C) 1992, 1993 Jean-loup Gailly
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.
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
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-
440 SunOS 5.8 Last change: local 8