tcompress.1 - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       tcompress.1 (5169B)
       ---
            1 .TH COMPRESS 1
            2 .SH NAME
            3 compress, uncompress, zcat \- compress and expand data
            4 .SH SYNOPSIS
            5 .B compress
            6 [
            7 .B \-f
            8 ] [
            9 .B \-v
           10 ] [
           11 .B \-c
           12 ] [
           13 .B \-V
           14 ] [
           15 .B \-b
           16 .I bits
           17 ] [
           18 .I "name \&..."
           19 ]
           20 .PP
           21 .B uncompress
           22 [
           23 .B \-f
           24 ] [
           25 .B \-v
           26 ] [
           27 .B \-c
           28 ] [
           29 .B \-V
           30 ] [
           31 .I "name \&..."
           32 ]
           33 .PP
           34 .B zcat
           35 [
           36 .B \-V
           37 ] [
           38 .I "name \&..."
           39 ]
           40 .SH DESCRIPTION
           41 .I Compress
           42 reduces the size of the named files using adaptive Lempel-Ziv coding.
           43 Whenever possible,
           44 each file is replaced by one with the extension
           45 .B "\&.Z,"
           46 while keeping the same ownership modes, access and modification times.
           47 If no files are specified, the standard input is compressed to the
           48 standard output.
           49 Compressed files can be restored to their original form using
           50 .I uncompress
           51 or
           52 .I zcat.
           53 .PP
           54 The
           55 .B \-f
           56 option will force compression of
           57 .I name.
           58 This is useful for compressing an entire directory,
           59 even if some of the files do not actually shrink.
           60 If
           61 .B \-f
           62 is not given and
           63 .I compress
           64 is run in the foreground,
           65 the user is prompted as to whether an existing file should be overwritten.
           66 .PP
           67 The
           68 .B \-c
           69 option makes
           70 .I compress/uncompress
           71 write to the standard output; no files are changed.
           72 The nondestructive behavior of
           73 .I zcat
           74 is identical to that of
           75 .I uncompress
           76 .B \-c.
           77 .PP
           78 .I Compress
           79 uses the modified Lempel-Ziv algorithm popularized in
           80 "A Technique for High Performance Data Compression",
           81 Terry A. Welch,
           82 .I "IEEE Computer,"
           83 vol. 17, no. 6 (June 1984), pp. 8-19.
           84 Common substrings in the file are first replaced by 9-bit codes 257 and up.
           85 When code 512 is reached, the algorithm switches to 10-bit codes and
           86 continues to use more bits until the
           87 limit specified by the
           88 .B \-b
           89 flag is reached (default 16).
           90 .I Bits
           91 must be between 9 and 16.  The default can be changed in the source to allow
           92 .I compress
           93 to be run on a smaller machine.
           94 .PP
           95 After the
           96 .I bits
           97 limit is attained,
           98 .I compress
           99 periodically checks the compression ratio.  If it is increasing,
          100 .I compress
          101 continues to use the existing code dictionary.  However,
          102 if the compression ratio decreases,
          103 .I compress
          104 discards the table of substrings and rebuilds it from scratch.  This allows
          105 the algorithm to adapt to the next "block" of the file.
          106 .PP
          107 Note that the
          108 .B \-b
          109 flag is omitted for
          110 .I uncompress,
          111 since the 
          112 .I bits
          113 parameter specified during compression
          114 is encoded within the output, along with
          115 a magic number to ensure that neither decompression of random data nor
          116 recompression of compressed data is attempted. 
          117 .PP
          118 .ne 8
          119 The amount of compression obtained depends on the size of the
          120 input, the number of
          121 .I bits
          122 per code, and the distribution of common substrings.
          123 Typically, text such as source code or English
          124 is reduced by 50\-60%.
          125 Compression is generally much better than that achieved by
          126 Huffman coding (as used in
          127 .IR pack ),
          128 or adaptive Huffman coding
          129 .RI ( compact ),
          130 and takes less time to compute.
          131 .PP
          132 Under the
          133 .B \-v
          134 option,
          135 a message is printed yielding the percentage of
          136 reduction for each file compressed.
          137 .PP
          138 If the
          139 .B \-V
          140 option is specified, the current version and compile options are printed on
          141 stderr.
          142 .PP
          143 Exit status is normally 0;
          144 if the last file is larger after (attempted) compression, the status is 2;
          145 if an error occurs, exit status is 1.
          146 .SH "SEE ALSO"
          147 pack(1), compact(1)
          148 .SH "DIAGNOSTICS"
          149 Usage: compress [\-dfvcV] [\-b maxbits] [file ...]
          150 .in +8
          151 Invalid options were specified on the command line.
          152 .in -8
          153 Missing maxbits
          154 .in +8
          155 Maxbits must follow
          156 .BR \-b \.
          157 .in -8
          158 .IR file :
          159 not in compressed format
          160 .in +8
          161 The file specified to
          162 .I uncompress
          163 has not been compressed.
          164 .in -8
          165 .IR file :
          166 compressed with 
          167 .I xx
          168 bits, can only handle 
          169 .I yy
          170 bits
          171 .in +8
          172 .I File
          173 was compressed by a program that could deal with
          174 more 
          175 .I bits
          176 than the compress code on this machine.
          177 Recompress the file with smaller
          178 .IR bits \.
          179 .in -8
          180 .IR file :
          181 already has .Z suffix -- no change
          182 .in +8
          183 The file is assumed to be already compressed.
          184 Rename the file and try again.
          185 .in -8
          186 .IR file :
          187 filename too long to tack on .Z
          188 .in +8
          189 The file cannot be compressed because its name is longer than
          190 12 characters.
          191 Rename and try again.
          192 This message does not occur on BSD systems.
          193 .in -8
          194 .I file
          195 already exists; do you wish to overwrite (y or n)?
          196 .in +8
          197 Respond "y" if you want the output file to be replaced; "n" if not.
          198 .in -8
          199 uncompress: corrupt input
          200 .in +8
          201 A SIGSEGV violation was detected which usually means that the input file has
          202 been corrupted.
          203 .in -8
          204 Compression: 
          205 .I "xx.xx%"
          206 .in +8
          207 Percentage of the input saved by compression.
          208 (Relevant only for
          209 .BR \-v \.)
          210 .in -8
          211 -- not a regular file: unchanged
          212 .in +8
          213 When the input file is not a regular file,
          214 (e.g. a directory), it is
          215 left unaltered.
          216 .in -8
          217 -- has 
          218 .I xx 
          219 other links: unchanged
          220 .in +8
          221 The input file has links; it is left unchanged.  See
          222 .IR ln "(1)"
          223 for more information.
          224 .in -8
          225 -- file unchanged
          226 .in +8
          227 No savings is achieved by
          228 compression.  The input remains virgin.
          229 .in -8
          230 .SH SOURCE
          231 .B \*9/src/cmd/compress/compress.c
          232 .SH "BUGS"
          233 Although compressed files are compatible between machines with large memory,
          234 .BR \-b \12
          235 should be used for file transfer to architectures with 
          236 a small process data space (64KB or less, as exhibited by the DEC PDP
          237 series, the Intel 80286, etc.)