Annotation of 43BSDReno/usr.bin/compress/compress.1, revision 1.1.1.1

1.1       root        1: .\" Copyright (c) 1986, 1990 The Regents of the University of California.
                      2: .\" All rights reserved.
                      3: .\"
                      4: .\" This code is derived from software contributed to Berkeley by
                      5: .\" James A. Woods, derived from original work by Spencer Thomas
                      6: .\" and Joseph Orost.
                      7: .\"
                      8: .\" Redistribution and use in source and binary forms are permitted provided
                      9: .\" that: (1) source distributions retain this entire copyright notice and
                     10: .\" comment, and (2) distributions including binaries display the following
                     11: .\" acknowledgement:  ``This product includes software developed by the
                     12: .\" University of California, Berkeley and its contributors'' in the
                     13: .\" documentation or other materials provided with the distribution and in
                     14: .\" all advertising materials mentioning features or use of this software.
                     15: .\" Neither the name of the University nor the names of its contributors may
                     16: .\" be used to endorse or promote products derived from this software without
                     17: .\" specific prior written permission.
                     18: .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     19: .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     20: .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     21: .\"
                     22: .\"     @(#)compress.1 6.8 (Berkeley) 7/24/90
                     23: .\"
                     24: .Dd July 24, 1990
                     25: .Dt COMPRESS 1
                     26: .Os BSD 4.3
                     27: .Sh NAME
                     28: .Nm compress ,
                     29: .Nm uncompress ,
                     30: .Nm zcat
                     31: .Nd compress and expand data
                     32: .Sh SYNOPSIS
                     33: .Nm compress
                     34: .Op Fl f
                     35: .Op Fl v
                     36: .Op Fl c
                     37: .Op Fl b Ar bits
                     38: .Ar
                     39: .br
                     40: .Nm uncompress
                     41: .Op Fl f
                     42: .Op Fl v
                     43: .Op Fl c
                     44: .Ar
                     45: .br
                     46: .Nm zcat
                     47: .Ar
                     48: .Sh DESCRIPTION
                     49: .Nm Compress
                     50: reduces the size of the named files using adaptive Lempel-Ziv coding.
                     51: Whenever possible,
                     52: each
                     53: .Ar file
                     54: is replaced by one with the extension
                     55: .Ar \&.Z ,
                     56: while keeping the same ownership modes, access and modification times.
                     57: If no files are specified, the standard input is compressed to the
                     58: standard output.
                     59: Compressed files can be restored to their original form using
                     60: .Nm uncompress
                     61: or
                     62: .Nm zcat
                     63: .Tw Ds
                     64: .Tp Fl f
                     65: Force compression of
                     66: .Ar file ,
                     67: even if it does not actually shrink
                     68: or the corresponding
                     69: .Ar file.Z
                     70: file already exists.
                     71: Except when run in the background under
                     72: .Pa /bin/sh ,
                     73: if
                     74: .Fl f
                     75: is not given the user is prompted as to whether an existing
                     76: .Ar file.Z
                     77: file should be overwritten.
                     78: .Pp
                     79: .Tp Fl c
                     80: (``cat'') makes
                     81: .Nm compress/uncompress
                     82: write to the standard output; no files are changed.
                     83: The nondestructive behavior of
                     84: .Nm zcat
                     85: is identical to that of
                     86: .Nm uncompress
                     87: .Fl c.
                     88: .Tp Fl b
                     89: Specify
                     90: .Ar bits
                     91: code limit (see below).
                     92: .Tp Fl v
                     93: Print the percentage reduction of each file.
                     94: .Tp
                     95: .Pp
                     96: .Nm Compress
                     97: uses the modified Lempel-Ziv algorithm popularized in
                     98: "A Technique for High Performance Data Compression",
                     99: Terry A. Welch,
                    100: .Em IEEE Computer ,
                    101: vol. 17, no. 6 (June 1984), pp. 8-19.
                    102: Common substrings in the file are first replaced by 9-bit codes 257 and up.
                    103: When code 512 is reached, the algorithm switches to 10-bit codes and
                    104: continues to use more bits until the
                    105: limit specified by the
                    106: .Fl b
                    107: flag is reached (default 16).
                    108: .Ar Bits
                    109: must be between 9 and 16.  The default can be changed in the source to allow
                    110: .Nm compress
                    111: to be run on a smaller machine.
                    112: .Pp
                    113: After the
                    114: .Ar bits
                    115: limit is attained,
                    116: .Nm compress
                    117: periodically checks the compression ratio.  If it is increasing,
                    118: .Nm compress
                    119: continues to use the existing code dictionary.  However,
                    120: if the compression ratio decreases,
                    121: .Nm compress
                    122: discards the table of substrings and rebuilds it from scratch.  This allows
                    123: the algorithm to adapt to the next "block" of the file.
                    124: .Pp
                    125: Note that the
                    126: .Fl b
                    127: flag is omitted for
                    128: .Ar uncompress
                    129: since the
                    130: .Ar bits
                    131: parameter specified during compression
                    132: is encoded within the output, along with
                    133: a magic number to ensure that neither decompression of random data nor
                    134: recompression of compressed data is attempted.
                    135: .Pp
                    136: .ne 8
                    137: The amount of compression obtained depends on the size of the
                    138: input, the number of
                    139: .Ar bits
                    140: per code, and the distribution of common substrings.
                    141: Typically, text such as source code or English
                    142: is reduced by 50\-60%.
                    143: Compression is generally much better than that achieved by
                    144: Huffman coding (as used in
                    145: .Xr pack ) ,
                    146: or adaptive Huffman coding (as
                    147: used in
                    148: .Xr compact ) ,
                    149: and takes less time to compute.
                    150: .Pp
                    151: If an error occurs, exit status is 1, else
                    152: if the last file was not compressed because it became larger, the status
                    153: is 2; else the status is 0.
                    154: .Sh DIAGNOSTICS
                    155: Usage: compress
                    156: .Op Fl fvc
                    157: .Op Fl b Ar maxbits
                    158: .Ar
                    159: .Dl Invalid options were specified on the command line.
                    160: .Pp
                    161: Missing maxbits
                    162: .Df I
                    163: Maxbits must follow
                    164: .Fl b .
                    165: .De
                    166: .Pp
                    167: .Ar file :
                    168: not in compressed format
                    169: .Df I
                    170: The file specified to
                    171: .Ar uncompress
                    172: has not been compressed.
                    173: .De
                    174: .Pp
                    175: .Ar file :
                    176: compressed with
                    177: .Ar xx
                    178: bits, can only handle
                    179: .Ar yy
                    180: bits
                    181: .Df I
                    182: .Ar File
                    183: was compressed by a program that could deal with
                    184: more
                    185: .Ar bits
                    186: than the compress code on this machine.
                    187: Recompress the file with smaller
                    188: .Ar bits .
                    189: .De
                    190: .Pp
                    191: .Ar file :
                    192: already has .Z suffix -- no change
                    193: .Df I
                    194: The file is assumed to be already compressed.
                    195: Rename the file and try again.
                    196: .De
                    197: .Pp
                    198: .Ar file :
                    199: filename too long to tack on .Z
                    200: .Df I
                    201: The file cannot be compressed because its name is longer than
                    202: 12 characters.
                    203: Rename and try again.
                    204: This message does not occur on BSD systems.
                    205: .De
                    206: .Pp
                    207: .Ar file
                    208: already exists; do you wish to overwrite (y or n)?
                    209: .Df I
                    210: Respond "y" if you want the output file to be replaced; "n" if not.
                    211: .De
                    212: .Pp
                    213: uncompress: corrupt input
                    214: .Df I
                    215: A SIGSEGV violation was detected which usually means that the input file is
                    216: corrupted.
                    217: .De
                    218: .Pp
                    219: Compression:
                    220: .Em xx.xx%
                    221: .Df I
                    222: Percentage of the input saved by compression.
                    223: (Relevant only for
                    224: .Fl v . )
                    225: .De
                    226: .Pp
                    227: -- not a regular file: unchanged
                    228: .Df I
                    229: When the input file is not a regular file,
                    230: (e.g. a directory), it is
                    231: left unaltered.
                    232: .De
                    233: .Pp
                    234: -- has
                    235: .Ar xx
                    236: other links: unchanged
                    237: .Df I
                    238: The input file has links; it is left unchanged.  See
                    239: .Xr ln 1
                    240: for more information.
                    241: .De
                    242: .Pp
                    243: -- file unchanged
                    244: .Df I
                    245: No savings is achieved by
                    246: compression.  The input remains virgin.
                    247: .De
                    248: .Pp
                    249: .Sh FILES
                    250: .Tw file.Z
                    251: .Tp Pa file.Z
                    252: compressed file is file.Z
                    253: .Tp
                    254: .Sh HISTORY
                    255: Appeared in 4.3 BSD.
                    256: .Sh "BUGS"
                    257: Although compressed files are compatible between machines with large memory,
                    258: .Cx Fl b
                    259: .Ar 12
                    260: .Cx
                    261: should be used for file transfer to architectures with
                    262: a small process data space (64KB or less, as exhibited by the DEC PDP
                    263: series, the Intel 80286, etc.)
                    264: .Pp
                    265: .Nm Compress
                    266: should be more flexible about the existence of the `.Z' suffix.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.