[BACK]Return to compress.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / compress

Annotation of src/usr.bin/compress/compress.1, Revision 1.5

1.5     ! denny       1: .\"    $OpenBSD: compress.1,v 1.4 1997/07/06 20:22:53 mickey Exp $
1.1       deraadt     2: .\"    $NetBSD: compress.1,v 1.5 1995/03/26 09:44:34 glass Exp $
                      3: .\"
                      4: .\" Copyright (c) 1986, 1990, 1993
                      5: .\"    The Regents of the University of California.  All rights reserved.
                      6: .\"
                      7: .\" This code is derived from software contributed to Berkeley by
                      8: .\" James A. Woods, derived from original work by Spencer Thomas
                      9: .\" and Joseph Orost.
                     10: .\"
                     11: .\" Redistribution and use in source and binary forms, with or without
                     12: .\" modification, are permitted provided that the following conditions
                     13: .\" are met:
                     14: .\" 1. Redistributions of source code must retain the above copyright
                     15: .\"    notice, this list of conditions and the following disclaimer.
                     16: .\" 2. Redistributions in binary form must reproduce the above copyright
                     17: .\"    notice, this list of conditions and the following disclaimer in the
                     18: .\"    documentation and/or other materials provided with the distribution.
                     19: .\" 3. All advertising materials mentioning features or use of this software
                     20: .\"    must display the following acknowledgement:
                     21: .\"    This product includes software developed by the University of
                     22: .\"    California, Berkeley and its contributors.
                     23: .\" 4. Neither the name of the University nor the names of its contributors
                     24: .\"    may be used to endorse or promote products derived from this software
                     25: .\"    without specific prior written permission.
                     26: .\"
                     27: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     28: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     29: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     30: .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     31: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     32: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     33: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     34: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     35: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     36: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     37: .\" SUCH DAMAGE.
                     38: .\"
                     39: .\"     @(#)compress.1 8.2 (Berkeley) 4/18/94
                     40: .\"
                     41: .Dd April 18, 1994
                     42: .Dt COMPRESS 1
                     43: .Os BSD 4.3
                     44: .Sh NAME
                     45: .Nm compress ,
                     46: .\".Nm uncompress ,
                     47: .Nm uncompress
                     48: .\".Nm zcat
                     49: .Nd compress and expand data
                     50: .Sh SYNOPSIS
                     51: .Nm compress
1.4       mickey     52: .Op Fl cftgOqv
1.1       deraadt    53: .Op Fl b Ar bits
1.4       mickey     54: .Op Fl o Ar filename
1.1       deraadt    55: .Op Ar
                     56: .Nm uncompress
1.4       mickey     57: .Op Fl cftoqv
                     58: .Op Fl o Ar filename
1.1       deraadt    59: .Op Ar
                     60: .\".Nm zcat
                     61: .\".Op Ar
                     62: .Sh DESCRIPTION
                     63: .Nm Compress
                     64: reduces the size of the named files using adaptive Lempel-Ziv coding.
                     65: Each
                     66: .Ar file
                     67: is renamed to the same name plus the extension
                     68: .Dq .Z .
                     69: As many of the modification time, access time, file flags, file mode,
                     70: user ID, and group ID as allowed by permissions are retained in the
                     71: new file.
                     72: If compression would not reduce the size of a
                     73: .Ar file ,
                     74: the file is ignored.
                     75: .Pp
                     76: .Nm Uncompress
                     77: restores the compressed files to their original form, renaming the
                     78: files by deleting the
                     79: .Dq .Z
                     80: extension.
                     81: .\".Pp
                     82: .\".Nm Zcat
                     83: .\"is an alias for
                     84: .\".Dq "uncompress -c" .
                     85: .Pp
                     86: If renaming the files would cause files to be overwritten and the standard
                     87: input device is a terminal, the user is prompted (on the standard error
                     88: output) for confirmation.
                     89: If prompting is not possible or confirmation is not received, the files
                     90: are not overwritten.
                     91: .Pp
                     92: If no files are specified, the standard input is compressed or uncompressed
                     93: to the standard output.
                     94: If either the input and output files are not regular files, the checks for
                     95: reduction in size and file overwriting are not performed, the input file is
                     96: not removed, and the attributes of the input file are not retained.
                     97: .Pp
                     98: The options are as follows:
                     99: .Bl -tag -width Ds
                    100: .It Fl b
                    101: Specify the
                    102: .Ar bits
                    103: code limit (see below).
                    104: .It Fl c
                    105: Compressed or uncompressed output is written to the standard output.
                    106: No files are modified.
1.4       mickey    107: .It Fl d
                    108: Decompress the source files instead of compressing them.
1.1       deraadt   109: .It Fl f
                    110: Force compression of
                    111: .Ar file ,
                    112: even if it is not actually reduced in size.
                    113: Additionally, files are overwritten without prompting for confirmation.
1.4       mickey    114: .It Fl g
                    115: Use deflate scheme wich reported to provide better compression rates.
                    116: .It Fl O
                    117: Use old compression method (default is based on the program name).
                    118: .It Fl o
                    119: Set the output file name.
                    120: .It Fl t
                    121: Test the entefrity of each file leaving any files intact.
                    122: .It Fl q
                    123: Be quite, suppress any messages.
1.1       deraadt   124: .It Fl v
                    125: Print the percentage reduction of each file.
                    126: .El
                    127: .Pp
                    128: .Nm Compress
                    129: uses a modified Lempel-Ziv algorithm.
                    130: Common substrings in the file are first replaced by 9-bit codes 257 and up.
                    131: When code 512 is reached, the algorithm switches to 10-bit codes and
                    132: continues to use more bits until the
                    133: limit specified by the
                    134: .Fl b
                    135: flag is reached (the default is 16).
                    136: .Ar Bits
                    137: must be between 9 and 16.
                    138: .Pp
                    139: After the
                    140: .Ar bits
                    141: limit is reached,
                    142: .Nm compress
                    143: periodically checks the compression ratio.
                    144: If it is increasing,
                    145: .Nm compress
                    146: continues to use the existing code dictionary.
                    147: However, if the compression ratio decreases,
                    148: .Nm compress
                    149: discards the table of substrings and rebuilds it from scratch.  This allows
                    150: the algorithm to adapt to the next "block" of the file.
                    151: .Pp
                    152: The
                    153: .Fl b
                    154: flag is omitted for
1.3       deraadt   155: .Nm uncompress
1.1       deraadt   156: since the
                    157: .Ar bits
                    158: parameter specified during compression
                    159: is encoded within the output, along with
                    160: a magic number to ensure that neither decompression of random data nor
                    161: recompression of compressed data is attempted.
                    162: .Pp
                    163: .ne 8
                    164: The amount of compression obtained depends on the size of the
                    165: input, the number of
                    166: .Ar bits
                    167: per code, and the distribution of common substrings.
                    168: Typically, text such as source code or English is reduced by 50\-60%.
                    169: Compression is generally much better than that achieved by Huffman
                    170: coding (as used in the historical command pack), or adaptive Huffman
                    171: coding (as used in the historical command compact), and takes less
                    172: time to compute.
                    173: .Pp
                    174: The
                    175: .Nm compress
1.5     ! denny     176: utility exits 0 on success, 1 if an error occurs, and 2 if one or
        !           177: more files were not compressed because they would have grown in
        !           178: size (and -f was not specifed).
1.1       deraadt   179: .Sh SEE ALSO
                    180: .Rs
                    181: .%A Welch, Terry A.
                    182: .%D June, 1984
                    183: .%T "A Technique for High Performance Data Compression"
                    184: .%J "IEEE Computer"
                    185: .%V 17:6
                    186: .%P pp. 8-19
                    187: .Re
1.5     ! denny     188: .Sh STANDARDS
        !           189: The
        !           190: .Nm compress
        !           191: utility is compliant with the
        !           192: .St -p1003.2-92
        !           193: specification.
1.1       deraadt   194: .Sh HISTORY
                    195: The
                    196: .Nm
                    197: command appeared in
                    198: .Bx 4.3 .
1.4       mickey    199: The deflate compression support added in
                    200: .Ox 2.1 .