GZIP(1) BSD Reference Manual GZIP(1)
gzip, gunzip, gzcat - compress and expand data (deflate mode)
gzip [-123456789cdfghLlNnOqrtVv] [-b bits] [-o filename] [-S suffix] [file ...] gunzip [-cfhlNnqrtv] [-o filename] [file ...] gzcat [-fghqr] [file ...]
The gzip utility reduces the size of the named files using adaptive Lempel-Ziv coding, in deflate mode. If invoked as gzip -O, the compress mode of compression is chosen; see compress(1) for more information. Each file is renamed to the same name plus the extension ".gz". As many of the modification time, access time, file flags, file mode, user ID, and group ID as allowed by permissions are retained in the new file. If compression would not reduce the size of a file, the file is ignored (unless -f is used). The gunzip utility restores compressed files to their original form, renaming the files by removing the extension (or by using the stored name if the -N flag is specified). It has the ability to restore files compressed by both gzip and compress(1), recognising the following exten- sions: ".Z", "-Z", "_Z", ".gz", "-gz", "_gz", ".cgz", "-cgz", "_cgz", ".ngz", "-ngz", "_ngz", ".tgz", "-tgz", "_tgz", ".taz", "-taz", and "_taz". Extensions ending in "tgz" and "taz" are not removed when decompressing, instead they are converted to "tar". The same goes for "cgz" and "ngz" files, which are converted to "cpio". The gzcat command is equivalent in functionality to gunzip -c. If renaming the files would cause files to be overwritten and the stan- dard input device is a terminal, the user is prompted (on the standard error output) for confirmation. If prompting is not possible or confirma- tion is not received, the files are not overwritten. If no files are specified, the standard input is compressed or un- compressed to the standard output. If either the input or output files are not regular files, the checks for reduction in size and file overwriting are not performed, the input file is not removed, and the at- tributes of the input file are not retained. By default, when compressing, the original file name and time stamp are stored in the compressed file. When uncompressing, this information is not used. Instead, the uncompressed file inherits the time stamp of the compressed version and the uncompressed file name is generated from the name of the compressed file as described above. These defaults may be overridden by the -N and -n flags, described below. The options are as follows: -1...9 Use the deflate scheme, with compression factor of -1 to -9. Compression factor -1 is the fastest, but provides a poorer level of compression. Compression factor -9 provides the best level of compression, but is relatively slow. The default is -6. This op- tion implies -g. -b bits Specify the bits code limit (see below). -c Compressed or uncompressed output is written to the standard out- put. No files are modified (force gzcat mode). -d Decompress the source files instead of compressing them (force gunzip mode). -f Force compression of file, even if it is not actually reduced in size. Additionally, files are overwritten without prompting for confirmation. If the input data is not in a format recognised by gzip and if the options -cd are also given, copy the input data without change to the standard output: let gzcat behave as cat(1). This option also turns off ignoring files based on their suffix. -g Use the deflate scheme, which reportedly provides better compres- sion rates (the default). -h Print a short help message. -L Print the licence. -l List information for the specified compressed files. The follow- ing information is listed: compressed size Size of the compressed file. uncompressed size Size of the file when uncompressed. compression ratio Ratio of the difference between the compressed and uncompressed sizes to the uncompressed size. uncompressed name Name the file will be saved as when un- compressing. If the -v option is specified, the following additional informa- tion is printed: compression method Name of the method used to compress the file. crc 32-bit CRC (cyclic redundancy code) of the uncompressed file. time stamp Date and time corresponding to the last data modification time (mtime) of the compressed file (if the -n option is specified, the time stamp stored in the compressed file is print- ed instead). -N When uncompressing or listing, use the time stamp and file name stored in the compressed file, if any, for the uncompressed ver- sion. -n When compressing, do not store the original file name and time stamp in the gzip header. -O Use old compression method (force compress(1) mode). -o filename Set the output file name. -q Be quiet: suppress all messages. -r Recursive mode: gzip will descend into specified directories. -S suffix Set the suffix for compressed files. -t Test the integrity of each file leaving any files intact. -V Display the programme version and exit. -v Print the percentage reduction of each file and other informa- tion. gzip uses a modified Lempel-Ziv algorithm (LZW). Common substrings are replaced by pointers to previous strings, and are found using a hash table. Unique substrings are emitted as a string of literal bytes, and compressed as Huffman trees. When code 512 is reached, the algorithm switches to 10-bit codes and continues to use more bits until the limit specified by the -b flag is reached. bits must be between 9 and 16 (the default is 16). After the bits limit is reached, gzip periodically checks the compression ratio. If it is increasing, gzip continues to use the existing code dic- tionary. However, if the compression ratio decreases, gzip discards the table of substrings and rebuilds it from scratch. This allows the algo- rithm to adapt to the next "block" of the file. The -b flag is omitted for gunzip since the bits parameter specified dur- ing compression is encoded within the output, along with a magic number to ensure that neither decompression of random data nor recompression of compressed data is attempted. The amount of compression obtained depends on the size of the input, the number of bits per code, and the distribution of common substrings. Typi- cally, text such as source code or English is reduced by 60 - 70% using gzip. Compression is generally much better than that achieved by Huffman coding (as used in the historical command pack), or adaptive Huffman cod- ing (as used in the historical command compact), and takes less time to compute. The gzip, gunzip, and gzcat utilities exit with 0 on success; 1 if an er- ror occurred; or 2 if a warning occurred.
GZIP Options which are passed to gzip, gunzip, and gzcat automatical- ly.
compress(1), cpio(1), gzexe(1), gzsig(1), zdiff(1), zforce(1), zmore(1), znew(1), compress(3) RFC 1950 ZLIB Compressed Data Format Specification. RFC 1951 DEFLATE Compressed Data Format Specification. RFC 1952 GZIP File Format Specification.
gzip compatibility was added to compress(1) in OpenBSD 3.4. The cpio han- dling was added in MirOS #8. The 'g' in this version of gzip stands for "gratis". MirOS BSD #10-current April 29, 2007 2
Generated on 2016-04-09 18:24:16 by $MirOS: src/scripts/roff2htm,v 1.83 2016/03/26 23:38:28 tg Exp $
These manual pages and other documentation are copyrighted by their respective writers;
their source is available at our CVSweb,
AnonCVS, and other mirrors. The rest is Copyright © 2002–2016 The MirOS Project, Germany.
This product includes material provided by mirabilos.
This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report – diffs preferred.