OSDN Git Service

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