1GZIP(1) General Commands Manual GZIP(1)
2
3
4
6 gzip, gunzip, zcat - compress or expand files
7
9 gzip [ -acdfhklLnNrtvV19 ] [-S suffix] [ name ... ]
10 gunzip [ -acfhklLnNrtvV ] [-S suffix] [ name ... ]
11 zcat [ -fhLV ] [ name ... ]
12
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 per 32 KiB block, or an
85 expansion ratio of 0.015% for large files. The actual number of used
86 disk blocks almost never increases.
87
88 gzip normally preserves the mode and modification timestamp of a file
89 when compressing or decompressing. If you have appropriate privileges,
90 it also preserves the file's owner and group.
91
93 -a --ascii
94 Ascii text mode: convert end-of-lines using local conventions.
95 This option is supported only on some non-Unix systems. For MS‐
96 DOS, CR LF is converted to LF when compressing, and LF is con‐
97 verted to CR LF when decompressing.
98
99 -c --stdout --to-stdout
100 Write output on standard output; keep original files unchanged.
101 If there are several input files, the output consists of a se‐
102 quence of independently compressed members. To obtain better
103 compression, concatenate all input files before compressing
104 them.
105
106 -d --decompress --uncompress
107 Decompress.
108
109 -f --force
110 Force compression or decompression even if the file has multiple
111 links or the corresponding file already exists, or if the com‐
112 pressed data is read from or written to a terminal. If the input
113 data is not in a format recognized by gzip, and if the option
114 --stdout is also given, copy the input data without change to
115 the standard output: let zcat behave as cat. If -f is not
116 given, and when not running in the background, gzip prompts to
117 verify whether an existing file should be overwritten.
118
119 -h --help
120 Display a help screen and quit.
121
122 -k --keep
123 Keep (don't delete) input files during compression or decompres‐
124 sion.
125
126 -l --list
127 For each compressed file, list the following fields:
128
129 compressed size: size of the compressed file
130 uncompressed size: size of the uncompressed file
131 ratio: compression ratio (0.0% if unknown)
132 uncompressed_name: name of the uncompressed file
133
134 The uncompressed size is given as -1 for files not in gzip for‐
135 mat, such as compressed .Z files. To get the uncompressed size
136 for such a file, you can use:
137
138 zcat file.Z | wc -c
139
140 In combination with the --verbose option, the following fields
141 are also displayed:
142
143 method: compression method
144 crc: the 32-bit CRC of the uncompressed data
145 date & time: timestamp for the uncompressed file
146
147 The compression methods currently supported are deflate, com‐
148 press, lzh (SCO compress -H) and pack. The crc is given as
149 ffffffff for a file not in gzip format.
150
151 With --name, the uncompressed name, date and time are those
152 stored within the compress file if present.
153
154 With --verbose, the size totals and compression ratio for all
155 files is also displayed, unless some sizes are unknown. With
156 --quiet, the title and totals lines are not displayed.
157
158 -L --license
159 Display the gzip license and quit.
160
161 -n --no-name
162 When compressing, do not save the original file name and time‐
163 stamp by default. (The original name is always saved if the name
164 had to be truncated.) When decompressing, do not restore the
165 original file name if present (remove only the gzip suffix from
166 the compressed file name) and do not restore the original time‐
167 stamp if present (copy it from the compressed file). This option
168 is the default when decompressing.
169
170 -N --name
171 When compressing, always save the original file name, and save
172 the seconds part of the original modification timestamp if the
173 original is a regular file and its timestamp is at least 1
174 (1970-01-01 00:00:01 UTC) and is less than 2**32 (2106-02-07
175 06:28:16 UTC, assuming leap seconds are not counted); this is
176 the default. When decompressing, restore from the saved file
177 name and timestamp if present. This option is useful on systems
178 which have a limit on file name length or when the timestamp has
179 been lost after a file transfer.
180
181 -q --quiet
182 Suppress all warnings.
183
184 -r --recursive
185 Travel the directory structure recursively. If any of the file
186 names specified on the command line are directories, gzip will
187 descend into the directory and compress all the files it finds
188 there (or decompress them in the case of gunzip ).
189
190 -S .suf --suffix .suf
191 When compressing, use suffix .suf instead of .gz. Any non-empty
192 suffix can be given, but suffixes other than .z and .gz should
193 be avoided to avoid confusion when files are transferred to
194 other systems.
195
196 When decompressing, add .suf to the beginning of the list of
197 suffixes to try, when deriving an output file name from an input
198 file name.
199
200 --synchronous
201 Use synchronous output. With this option, gzip is less likely
202 to lose data during a system crash, but it can be considerably
203 slower.
204
205 -t --test
206 Test. Check the compressed file integrity then quit.
207
208 -v --verbose
209 Verbose. Display the name and percentage reduction for each file
210 compressed or decompressed.
211
212 -V --version
213 Version. Display the version number and compilation options then
214 quit.
215
216 -# --fast --best
217 Regulate the speed of compression using the specified digit #,
218 where -1 or --fast indicates the fastest compression method
219 (less compression) and -9 or --best indicates the slowest com‐
220 pression method (best compression). The default compression
221 level is -6 (that is, biased towards high compression at expense
222 of speed).
223
224 --rsyncable
225 When you synchronize a compressed file between two computers,
226 this option allows rsync to transfer only files that were
227 changed in the archive instead of the entire archive. Normally,
228 after a change is made to any file in the archive, the compres‐
229 sion algorithm can generate a new version of the archive that
230 does not match the previous version of the archive. In this
231 case, rsync transfers the entire new version of the archive to
232 the remote computer. With this option, rsync can transfer only
233 the changed files as well as a small amount of metadata that is
234 required to update the archive structure in the area that was
235 changed.
236
238 Multiple compressed files can be concatenated. In this case, gunzip
239 will extract all members at once. For example:
240
241 gzip -c file1 > foo.gz
242 gzip -c file2 >> foo.gz
243
244 Then
245
246 gunzip -c foo
247
248 is equivalent to
249
250 cat file1 file2
251
252 In case of damage to one member of a .gz file, other members can still
253 be recovered (if the damaged member is removed). However, you can get
254 better compression by compressing all members at once:
255
256 cat file1 file2 | gzip > foo.gz
257
258 compresses better than
259
260 gzip -c file1 file2 > foo.gz
261
262 If you want to recompress concatenated files to get better compression,
263 do:
264
265 gzip -cd old.gz | gzip > new.gz
266
267 If a compressed file consists of several members, the uncompressed size
268 and CRC reported by the --list option applies to the last member only.
269 If you need the uncompressed size for all members, you can use:
270
271 gzip -cd file.gz | wc -c
272
273 If you wish to create a single archive file with multiple members so
274 that members can later be extracted independently, use an archiver such
275 as tar or zip. GNU tar supports the -z option to invoke gzip transpar‐
276 ently. gzip is designed as a complement to tar, not as a replacement.
277
279 The obsolescent environment variable GZIP can hold a set of default op‐
280 tions for gzip. These options are interpreted first and can be over‐
281 written by explicit command line parameters. As this can cause prob‐
282 lems when using scripts, this feature is supported only for options
283 that are reasonably likely to not cause too much harm, and gzip warns
284 if it is used. This feature will be removed in a future release of
285 gzip.
286
287 You can use an alias or script instead. For example, if gzip is in the
288 directory /usr/bin you can prepend $HOME/bin to your PATH and create an
289 executable script $HOME/bin/gzip containing the following:
290
291 #! /bin/sh
292 export PATH=/usr/bin
293 exec gzip -9 "$@"
294
296 znew(1), zcmp(1), zmore(1), zforce(1), gzexe(1), zip(1), unzip(1), com‐
297 press(1)
298
299 The gzip file format is specified in P. Deutsch, GZIP file format spec‐
300 ification version 4.3, <https://www.ietf.org/rfc/rfc1952.txt>, Internet
301 RFC 1952 (May 1996). The zip deflation format is specified in P.
302 Deutsch, DEFLATE Compressed Data Format Specification version 1.3,
303 <https://www.ietf.org/rfc/rfc1951.txt>, Internet RFC 1951 (May 1996).
304
306 Exit status is normally 0; if an error occurs, exit status is 1. If a
307 warning occurs, exit status is 2.
308
309 Usage: gzip [-cdfhklLnNrtvV19] [-S suffix] [file ...]
310 Invalid options were specified on the command line.
311
312 file: not in gzip format
313 The file specified to gunzip has not been compressed.
314
315 file: Corrupt input. Use zcat to recover some data.
316 The compressed file has been damaged. The data up to the point
317 of failure can be recovered using
318
319 zcat file > recover
320
321 file: compressed with xx bits, can only handle yy bits
322 File was compressed (using LZW) by a program that could deal
323 with more bits than the decompress code on this machine. Recom‐
324 press the file with gzip, which compresses better and uses less
325 memory.
326
327 file: already has .gz suffix -- unchanged
328 The file is assumed to be already compressed. Rename the file
329 and try again.
330
331 file already exists; do you wish to overwrite (y or n)?
332 Respond "y" if you want the output file to be replaced; "n" if
333 not.
334
335 gunzip: corrupt input
336 A SIGSEGV violation was detected which usually means that the
337 input file has been corrupted.
338
339 xx.x% Percentage of the input saved by compression.
340 (Relevant only for -v and -l.)
341
342 -- not a regular file or directory: ignored
343 When the input file is not a regular file or directory, (e.g. a
344 symbolic link, socket, FIFO, device file), it is left unaltered.
345
346 -- has xx other links: unchanged
347 The input file has links; it is left unchanged. See ln(1) for
348 more information. Use the -f flag to force compression of multi‐
349 ply-linked files.
350
352 When writing compressed data to a tape, it is generally necessary to
353 pad the output with zeroes up to a block boundary. When the data is
354 read and the whole block is passed to gunzip for decompression, gunzip
355 detects that there is extra trailing garbage after the compressed data
356 and emits a warning by default. You can use the --quiet option to sup‐
357 press the warning.
358
360 In some rare cases, the --best option gives worse compression than the
361 default compression level (-6). On some highly redundant files, com‐
362 press compresses better than gzip.
363
365 Report bugs to: bug-gzip@gnu.org
366 GNU gzip home page: <https://www.gnu.org/software/gzip/>
367 General help using GNU software: <https://www.gnu.org/gethelp/>
368
370 Copyright © 1998-1999, 2001-2002, 2012, 2015-2022 Free Software Founda‐
371 tion, Inc.
372 Copyright © 1992, 1993 Jean-loup Gailly
373
374 Permission is granted to make and distribute verbatim copies of this
375 manual provided the copyright notice and this permission notice are
376 preserved on all copies.
377
378 Permission is granted to copy and distribute modified versions of this
379 manual under the conditions for verbatim copying, provided that the en‐
380 tire resulting derived work is distributed under the terms of a permis‐
381 sion notice identical to this one.
382
383 Permission is granted to copy and distribute translations of this man‐
384 ual into another language, under the above conditions for modified ver‐
385 sions, except that this permission notice may be stated in a transla‐
386 tion approved by the Foundation.
387
388
389
390 local GZIP(1)