'\"macro stdmacro
.if n .pH g1.compress @(#)compress	40.9 of 10/10/89
.\" Copyright 1989 AT&T
.\" @(#)compress.1 1.5 88/10/17 SMI; from UCB 6.5 5/11/86
.\" Copyright (c) 1988 Sun Microsystems, Inc - All Rights Reserved.
.nr X
.if \nX=0 .ds x} compress 1 "Directory and File Management Utilities" "\&"
.if \nX=1 .ds x} compress 1 "Directory and File Management Utilities"
.if \nX=2 .ds x} compress 1 "" "\&"
.if \nX=3 .ds x} compress "" "" "\&"
.TH \*(x}
.SH NAME
\f4compress\f1, \f4uncompress\f1, \f4zcat\f1 \- compress, expand or display expanded files
.SH SYNOPSIS
\f4compress\f1
\f1[\f4 \-cfv \f1]
[
\f4\-b\f1
.I bits
] 
[
.IR filename \&.\|.\|.
]
.br
\f4uncompress\f1
\f1[\f4 \-cv \f1]
[
.IR filename \&.\|.\|.
]
.br
\f4zcat\f1
[
.IR filename .\|.\|.
]
.SH DESCRIPTION
.PP
\f4compress\f1
reduces the size of the named files using
adaptive Lempel-Ziv coding.
Whenever possible, each file is replaced by one with a
\f4\&.\|Z\f1,
extension.
The ownership modes, access time  and
modification time will stay the same.
If no files are specified, the standard input is compressed to the
standard output.
.P
The amount of compression obtained depends on the size of the
input, the number of
.I bits
per code, and the distribution of common substrings.
Typically, text such as source code or English
is reduced by 50\-60%.
Compression is generally much better than that achieved by
Huffman coding [as used in
\f4pack\f1(1)],
and takes less time to compute.
The 
.I bits 
parameter specified during compression is encoded within
the compressed
file, along with a magic number to ensure that neither
decompression of 
random data nor recompression of compressed data is subsequently
allowed. 
.P
Compressed files can be restored to their original form using
\f4uncompress\f1.
.P
\f4zcat \f1
produces uncompressed output on the standard output, but leaves
the compressed 
\f4\&.\|Z\f1
file intact.
.SH OPTIONS
.TP
\f4\-c\f1
Write to the standard output; no files are changed.
The nondestructive behavior of
\f4zcat\f1
is identical to that of
\f1`\f4uncompress \-c\f1'.
.TP
\f4\-f\f1
Force compression,
even if the file does not actually shrink,
or the corresponding
\f4\&.\|Z\f1
file already exists.
Except when running in the background (under
\f4/usr/bin/sh\f1),
if
\f4\-f\f1
is not given,
prompt to verify whether an existing
\f4\&.\|Z\f1
file should be overwritten.
.TP
\f4\-v\f1
Verbose.
Display the percentage reduction for each file compressed.
.TP
\f4\-b\f2 bits\f1
Set the upper limit (in bits) for common substring codes.
.I bits
must be between 9 and 16 (16 is the default).
Lowering the number of bits will result in larger,
less compressed files.
.SH FILES
.TP 20
\f4/usr/bin/sh\f1
.SH SEE ALSO
\f4pack\f1(1)
.P
.IR "A Technique for High Performance Data Compression" ,
Terry A. Welch,
.IR "IEEE Computer" ,
vol. 17, no. 6 (June 1984), pp. 8-19.
.SH DIAGNOSTICS
Exit status is normally \f40\f1.
If the last file was not compressed because it became
larger, the status
is \f42\f1.
If an error occurs, exit status is \f41\f1.
.TP 10
\f4Usage: compress [\-fvc] [\-b maxbits] [\f2filename .\|.\|.\f4]\f1
Invalid options were specified on the command line.
.TP
\f4Missing maxbits\f1
Maxbits must follow
\f4\-b\f1.
.TP
\f2filename\f4: not in compressed format\f1
The file specified to
\f4uncompress\f1
has not been compressed.
.br
.ne 3
.TP
\f2filename\f4: compressed with \f2xx\f4bits, can only handle \f2yy\f4bits\f1
.I filename
was compressed by a program that could deal with
more
.I bits
than the compress code on this machine.
Recompress the file with smaller
.IR bits .
.br
.ne 5
.TP
\f2filename\f4: already has .\|Z suffix -- no change\f1
The file is assumed to be already compressed.
Rename the file and try again.
.\".TP
.\".IR filename ": filename too long to tack on .\|Z"
.\"The file cannot be compressed because its name is longer than
.\"12 characters.
.\"Rename and try again.
.\"This message does not occur on BSD systems.
.TP
\f2filename\f4: already exists; do you wish to overwrite (y or n)?\f1
Respond
\f4y\f1
if you want the output file to be replaced;
\f4n\f1
if not.
.TP
\f4uncompress: corrupt input\f1
A \f4SIGSEGV\f1
violation was detected, which usually means that the input
file is corrupted.
.TP
\f4Compression:\f2  xx.xx\f4%\f1
Percentage of the input saved by compression.
(Relevant only for
\f4\-v\f1\.)
.TP
\f4\-\|\- not a regular file: unchanged\f1
When the input file is not a regular file, (such as a
directory), it is left unaltered.
.TP
\f4\-\|\- has \f2xx\f4 other links: unchanged\f1
The input file has links; it is left unchanged.  See
\f4ln\f1(1)
for more information.
.TP
\f4\-\|\- file unchanged\f1
No savings are achieved by compression.
The input remains uncompressed.
.SH "NOTES"
Although compressed files are compatible between
machines with large memory,
\f4\-b\f112
should be used for file transfer to architectures with 
a small process data space (64KB or less).
.P
\f4compress\f1
should be more flexible about the existence of the
\f4\&.\|Z\f1
suffix.
