version 1.34, 2005/07/22 09:30:51 |
version 1.35, 2007/01/24 10:53:43 |
|
|
.Sh NAME |
.Sh NAME |
.Nm compress , |
.Nm compress , |
.Nm uncompress , |
.Nm uncompress , |
.Nm gzip , |
.Nm zcat |
.Nm gunzip , |
.Nd compress and expand data (compress mode) |
.Nm zcat , |
|
.Nm gzcat |
|
.Nd compress and expand data |
|
.Sh SYNOPSIS |
.Sh SYNOPSIS |
.Nm compress |
.Nm compress |
.Op Fl LV |
.Op Fl 123456789cdfghLlNnOqrtVv |
.Nm compress |
|
.Op Fl 123456789cdfghlNnOqrtv |
|
.Op Fl b Ar bits |
.Op Fl b Ar bits |
.Op Fl o Ar filename |
.Op Fl o Ar filename |
.Op Fl S Ar suffix |
.Op Fl S Ar suffix |
|
|
.Op Fl cfhlNnqrtv |
.Op Fl cfhlNnqrtv |
.Op Fl o Ar filename |
.Op Fl o Ar filename |
.Op Ar |
.Op Ar |
.Pp |
|
.Nm gzip |
|
.Op Fl LV |
|
.Nm gzip |
|
.Op Fl 123456789cdfghlNnOqrtv |
|
.Op Fl b Ar bits |
|
.Op Fl o Ar filename |
|
.Op Fl S Ar suffix |
|
.Op Ar |
|
.Nm gunzip |
|
.Op Fl cfhlNnqrtv |
|
.Op Fl o Ar filename |
|
.Op Ar |
|
.Pp |
|
.Nm zcat |
.Nm zcat |
.Op Fl fghqr |
.Op Fl fghqr |
.Op Ar |
.Op Ar |
.Nm gzcat |
|
.Op Fl fghqr |
|
.Op Ar |
|
.Sh DESCRIPTION |
.Sh DESCRIPTION |
The |
The |
.Nm compress |
.Nm |
and |
utility |
.Nm gzip |
reduces the size of the named files using adaptive Lempel-Ziv coding, |
utilities |
in compress mode. |
reduce the size of the named files using adaptive Lempel-Ziv coding. |
|
They are functionally identical, but use different algorithms for compression. |
|
If invoked as |
If invoked as |
.Nm gzip |
|
or |
|
.Nm compress Fl g , |
.Nm compress Fl g , |
the deflate mode of compression is chosen by default; |
the deflate mode of compression is chosen; |
otherwise the older method of compression |
see |
.Pq compress mode |
.Xr gzip 1 |
is used. |
for more information. |
.Pp |
Each file is renamed to the same name plus the extension |
Each |
.Dq .Z . |
.Ar file |
|
is renamed to the same name plus the extension |
|
.Dq .Z , |
|
or |
|
.Dq .gz |
|
(in deflate mode). |
|
As many of the modification time, access time, file flags, file mode, |
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 |
user ID, and group ID as allowed by permissions are retained in the |
new file. |
new file. |
If compression would not reduce the size of a |
If compression would not reduce the size of a file, |
.Ar file , |
|
the file is ignored (unless |
the file is ignored (unless |
.Fl f |
.Fl f |
is used). |
is used). |
.Pp |
.Pp |
The |
The |
.Nm uncompress |
.Nm uncompress |
and |
utility restores compressed files to their original form, renaming the |
.Nm gunzip |
|
utilities restore compressed files to their original form, renaming the |
|
files by removing the extension (or by using the stored name if the |
files by removing the extension (or by using the stored name if the |
.Fl N |
.Fl N |
flag is specified). |
flag is specified). |
When decompressing, the following extensions are recognized: |
It has the ability to restore files compressed by both |
|
.Nm |
|
and |
|
.Xr gzip 1 , |
|
recognising the following extensions: |
.Dq .Z , |
.Dq .Z , |
.Dq -Z , |
.Dq -Z , |
.Dq _Z , |
.Dq _Z , |
|
|
command is equivalent in functionality to |
command is equivalent in functionality to |
.Nm uncompress |
.Nm uncompress |
.Fl c . |
.Fl c . |
The |
|
.Nm gzcat |
|
command is equivalent in functionality to |
|
.Nm gunzip |
|
.Fl c . |
|
.Pp |
.Pp |
If renaming the files would cause files to be overwritten and the standard |
If renaming the files would cause files to be overwritten and the standard |
input device is a terminal, the user is prompted (on the standard error |
input device is a terminal, the user is prompted (on the standard error |
|
|
The options are as follows: |
The options are as follows: |
.Bl -tag -width Ds |
.Bl -tag -width Ds |
.It Fl 1...9 |
.It Fl 1...9 |
Use deflate scheme with compression factor of |
Use the deflate scheme, with compression factor of |
.Fl 1 |
.Fl 1 |
to |
to |
.Fl 9 . |
.Fl 9 . |
|
|
Compressed or uncompressed output is written to the standard output. |
Compressed or uncompressed output is written to the standard output. |
No files are modified (force |
No files are modified (force |
.Nm zcat |
.Nm zcat |
or |
|
.Nm gzcat |
|
mode). |
mode). |
.It Fl d |
.It Fl d |
Decompress the source files instead of compressing them (force |
Decompress the source files instead of compressing them (force |
|
|
is also given, copy the input data without change |
is also given, copy the input data without change |
to the standard output: let |
to the standard output: let |
.Nm zcat |
.Nm zcat |
or |
|
.Nm gzcat |
|
behave as |
behave as |
.Xr cat 1 . |
.Xr cat 1 . |
.It Fl g |
.It Fl g |
Use deflate scheme which reportedly provides better compression rates (force |
Use the deflate scheme, which reportedly provides better compression rates |
.Nm gzip |
(force |
|
.Xr gzip 1 |
mode). |
mode). |
This flag need not be specified when invoked as |
|
.Nm gzip |
|
or |
|
.Nm gzcat . |
|
.It Fl h |
.It Fl h |
Print a short help message. |
Print a short help message. |
|
.It Fl L |
|
Print the license. |
.It Fl l |
.It Fl l |
List information for the specified compressed files. |
List information for the specified compressed files. |
The following information is listed: |
The following information is listed: |
|
|
.It Fl N |
.It Fl N |
When compressing, save the original file name and time stamp in the |
When compressing, save the original file name and time stamp in the |
compressed file. |
compressed file. |
This information is saved by default when the deflate scheme is used. |
This information is saved by default when the deflate scheme |
|
.Pf ( Fl g ) |
|
is used. |
When uncompressing or listing, use the time stamp and file name stored |
When uncompressing or listing, use the time stamp and file name stored |
in the compressed file, if any, for the uncompressed version. |
in the compressed file, if any, for the uncompressed version. |
.It Fl n |
.It Fl n |
When compressing, do not save the original file name and time stamp. |
When compressing, do not save the original file name and time stamp. |
This information is saved by default when the deflate scheme is used. |
This information is saved by default when the deflate scheme |
|
.Pf ( Fl g ) |
|
is used. |
When uncompressing, do not restore the original file name and time stamp. |
When uncompressing, do not restore the original file name and time stamp. |
By default, the uncompressed file inherits the time stamp of the |
By default, the uncompressed file inherits the time stamp of the |
compressed version and the uncompressed file name is generated from |
compressed version and the uncompressed file name is generated from |
the name of the compressed file name as described above. |
the name of the compressed file name as described above. |
.It Fl O |
.It Fl O |
Use old compression method. |
Use compress mode |
|
(the default). |
.It Fl o Ar filename |
.It Fl o Ar filename |
Set the output file name. |
Set the output file name. |
.It Fl q |
.It Fl q |
Be quiet, suppress all messages. |
Be quiet: suppress all messages. |
.It Fl r |
.It Fl r |
Recursive mode, |
Recursive mode: |
.Nm |
.Nm |
will descend into specified directories. |
will descend into specified directories. |
.It Fl S Ar suffix |
.It Fl S Ar suffix |
Set suffix for compressed files. |
Set the suffix for compressed files. |
.It Fl t |
.It Fl t |
Test the integrity of each file leaving any files intact. |
Test the integrity of each file leaving any files intact. |
.It Fl V |
.It Fl V |
|
|
Print the percentage reduction of each file and other information. |
Print the percentage reduction of each file and other information. |
.El |
.El |
.Pp |
.Pp |
In normal mode, |
|
.Nm |
.Nm |
uses a modified Lempel-Ziv algorithm |
uses a modified Lempel-Ziv algorithm |
.Pq LZW . |
.Pq LZW . |
|
|
.Dq block |
.Dq block |
of the file. |
of the file. |
.Pp |
.Pp |
.Nm gzip |
|
uses a slightly different version of the Lempel-Ziv algorithm |
|
.Pq LZ77 . |
|
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. |
|
.Pp |
|
The |
The |
.Fl b |
.Fl b |
flag is omitted for |
flag is omitted for |
.Nm uncompress |
.Nm uncompress |
or |
|
.Nm gunzip |
|
since the |
since the |
.Ar bits |
.Ar bits |
parameter specified during compression |
parameter specified during compression |
|
|
.Ar bits |
.Ar bits |
per code, and the distribution of common substrings. |
per code, and the distribution of common substrings. |
Typically, text such as source code or English is reduced by 50 \- 60% using |
Typically, text such as source code or English is reduced by 50 \- 60% using |
.Nm |
.Nm . |
and by 60 \- 70% using |
|
.Nm gzip . |
|
Compression is generally much better than that achieved by Huffman |
Compression is generally much better than that achieved by Huffman |
coding (as used in the historical command pack), or adaptive Huffman |
coding (as used in the historical command pack), or adaptive Huffman |
coding (as used in the historical command compact), and takes less |
coding (as used in the historical command compact), and takes less |
time to compute. |
time to compute. |
.Pp |
.Pp |
The |
The |
.Nm |
.Nm compress , |
|
.Nm uncompress , |
and |
and |
.Nm gzip |
.Nm zcat |
utilities exit with 0 on success; 1 if an error occurred; |
utilities exit with 0 on success; 1 if an error occurred; |
or 2 if a warning occurred. |
or 2 if a warning occurred. |
.Sh SEE ALSO |
.Sh SEE ALSO |
.Xr gzexe 1 , |
.Xr gzexe 1 , |
|
.Xr gzip 1 , |
.Xr zdiff 1 , |
.Xr zdiff 1 , |
.Xr zforce 1 , |
.Xr zforce 1 , |
.Xr zmore 1 , |
.Xr zmore 1 , |
|
|
.%V 17:6 |
.%V 17:6 |
.%P pp. 8\-19 |
.%P pp. 8\-19 |
.Re |
.Re |
.Pp |
|
.Bl -tag -width 12n -compact |
|
.It RFC 1950 |
|
ZLIB Compressed Data Format Specification. |
|
.It RFC 1951 |
|
DEFLATE Compressed Data Format Specification. |
|
.It RFC 1952 |
|
GZIP File Format Specification. |
|
.El |
|
.Sh STANDARDS |
.Sh STANDARDS |
The |
The |
.Nm |
.Nm |
utility is compliant with the |
utility is compliant with the |
.St -p1003.2-92 |
.St -p1003.2-92 |
specification. |
specification. |
.Pp |
|
The |
|
.Nm gzip |
|
and |
|
.Nm gunzip |
|
utilities are extensions. |
|
.Sh HISTORY |
.Sh HISTORY |
The |
The |
.Nm |
.Nm |
command appeared in |
command appeared in |
.Bx 4.3 . |
.Bx 4.3 . |
The deflate compression support was added in |
Deflate compression support was added in |
.Ox 2.1 . |
.Ox 2.1 . |
Full |
|
.Nm gzip |
|
compatibility was added in |
|
.Ox 3.4 . |
|
The |
|
.Sq g |
|
in this version of |
|
.Nm gzip |
|
stands for |
|
.Dq gratis . |
|