compress
Compress files using Lempel-Ziv coding
TLDR
Compress specific files
Compress specific files, ignore non-existent ones
Specify the maximum compression bits (9-16 bits)
Write to stdout (no files are changed)
Decompress files (functions like uncompress)
Display compression percentage
SYNOPSIS
compress [-dfvc] [-b maxbits] [file …]
PARAMETERS
-b maxbits
Maximum bits per code (9-16, default 12)
-c
Write compressed data to stdout (no .Z files)
-d
Decompress instead of compressing
-f
Force compression, even if file grows or is symlink
-v
Verbose: print compression factor for each file
DESCRIPTION
The compress command is an early Unix utility that reduces file sizes using the adaptive Lempel-Ziv-Welch (LZW) algorithm, a dictionary-based method developed in the early 1980s. It processes one or more input files, replacing each with a compressed version suffixed by .Z (e.g., file.txt becomes file.txt.Z). Original files are removed unless the -c option directs output to stdout.
Unlike modern tools like gzip, compress does not support tar archives or multi-file concatenation natively and produces lower compression ratios. It excels on text files, achieving 2-3x reduction typically. Decompression uses compress -d or the separate uncompress command; gzip -d also handles .Z files for compatibility.
Primarily historical, it's rarely used today due to patent issues with LZW (expired 2003) and superior alternatives. Available via ncompress package on Linux. Verbose mode reports compression stats, like percentage saved.
CAVEATS
Obsolete; poor ratios vs gzip. Not default-installed. LZW patents delayed adoption. Avoid for new use.
EXAMPLE
compress -v file.txt
Replaces file.txt with file.txt.Z, shows ratio.
compress -dc file.Z
Outputs decompressed data to stdout.
HISTORY
Originated in 2.0BSD (1983), based on 1982 LZW paper by Welch et al. Ported to SVR3. Supplanted by gzip (1992) amid patent disputes.
SEE ALSO
gzip(1), uncompress(1), pack(1), bzip2(1), xz(1)


