1 .\" $NetBSD: compress.1,v 1.13 2003/01/23 08:53:46 wiz Exp $
3 .\" Copyright (c) 1986, 1990, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software contributed to Berkeley by
7 .\" James A. Woods, derived from original work by Spencer Thomas
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
18 .\" 3. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" @(#)compress.1 8.2 (Berkeley) 4/18/94
44 .Nd compress and expand data
57 reduces the size of the named files using adaptive Lempel-Ziv coding.
60 is renamed to the same name plus the extension
62 As many of the modification time, access time, file flags, file mode,
63 user ID, and group ID as allowed by permissions are retained in the
65 If compression would not reduce the size of a
70 restores the compressed files to their original form, renaming the
77 .\".Dq "uncompress -c" .
79 If renaming the files would cause files to be overwritten and the standard
80 input device is a terminal, the user is prompted (on the standard error
81 output) for confirmation.
82 If prompting is not possible or confirmation is not received, the files
85 If no files are specified, the standard input is compressed or uncompressed
86 to the standard output.
87 If either the input and output files are not regular files, the checks for
88 reduction in size and file overwriting are not performed, the input file is
89 not removed, and the attributes of the input file are not retained.
91 The options are as follows:
96 code limit (see below).
98 Compressed or uncompressed output is written to the standard output.
99 No files are modified.
105 even if it is not actually reduced in size.
106 Additionally, files are overwritten without prompting for confirmation.
108 Print the percentage reduction of each file.
112 uses a modified Lempel-Ziv algorithm.
113 Common substrings in the file are first replaced by 9-bit codes 257 and up.
114 When code 512 is reached, the algorithm switches to 10-bit codes and
115 continues to use more bits until the
116 limit specified by the
118 flag is reached (the default is 16).
120 must be between 9 and 16.
126 periodically checks the compression ratio.
129 continues to use the existing code dictionary.
130 However, if the compression ratio decreases,
132 discards the table of substrings and rebuilds it from scratch. This allows
133 the algorithm to adapt to the next "block" of the file.
141 parameter specified during compression
142 is encoded within the output, along with
143 a magic number to ensure that neither decompression of random data nor
144 recompression of compressed data is attempted.
146 The amount of compression obtained depends on the size of the
149 per code, and the distribution of common substrings.
150 Typically, text such as source code or English is reduced by 50\-60%.
151 Compression is generally much better than that achieved by Huffman
152 coding (as used in the historical command pack), or adaptive Huffman
153 coding (as used in the historical command compact), and takes less
158 utility exits 0 on success, and \*[Gt]0 if an error occurs.
164 .%T "A Technique for High Performance Data Compression"