Andrew Mercer
on this page

compress (.Z)

Format: .Z · Algorithm: LZW (Lempel–Ziv–Welch) · First released: 1984–85 (Spencer Thomas, Joe Orost and others)

compress was the standard Unix compressor through the late 1980s. It implemented Terry Welch's 1984 LZW algorithm and produced the .Z files (and .tar.Z tarballs) that filled early FTP archives.

The patent story

LZW was patented, first by Sperry and then Unisys. When Unisys began demanding royalties in the early 1990s (the same patent famously affected GIF images), the free-software world needed an unencumbered alternative. The GNU project released gzip in 1992, built on patent-free DEFLATE, and .tar.gz replaced .tar.Z within a few years. The patents expired in 2003–2004.

Using it today

You'll rarely create .Z files, but you may need to read them. gzip can decompress them directly:

gzip -d file.Z           # or gunzip file.Z
zcat file.Z
tar xzf archive.tar.Z    # GNU tar handles .Z via gzip
tar xf archive.tar.Z     # auto-detected

If you do need the original tool, it's packaged as ncompress on most distros:

compress file            # -> file.Z, removes file
compress -c file > out.Z
uncompress file.Z
compress -b 12 file      # limit code size (needed for some old systems)

tar -Z also creates .tar.Z if compress is installed.

Even older: pack and compact

Tool Ext. Algorithm Notes
pack / unpack / pcat .z (lowercase) Static Huffman 1970s AT&T Unix. gzip -d can read .z files made by pack.
compact / uncompact / ccat .C Adaptive Huffman Early BSD. Slow and quickly displaced by compress.

Watch the case: lowercase .z is pack (and very early gzip versions), uppercase .Z is compress.

See also

  • gzip — the replacement
  • Overview — other historical formats