pack
Compress files using Huffman encoding
SYNOPSIS
pack [ - ] [ -f ] [ -o ] name ...
PARAMETERS
-
When specified as the first argument, pack displays the percentage of reduction for each file and a checksum of the input and output files.
-f
Forces compression even if it does not result in a smaller file, or if the file is already packed. By default, pack will not compress a file if the packed version is not smaller than the original.
-o
If a packed file (e.g., name.z) already exists, pack will overwrite it. Without this option, pack will exit with an error if the target .z file already exists.
DESCRIPTION
pack is an older Unix utility designed to compress files using Huffman coding. It aims to reduce file size by encoding frequently occurring characters with shorter bit sequences. When a file is packed, its original content is replaced by the compressed version, and the filename gains a .z suffix (e.g., file.txt becomes file.txt.z). pack is typically used for individual files, unlike archivers like tar which group multiple files.
While historically significant, it has largely been superseded by more efficient compression algorithms and tools like gzip, bzip2, and xz, which offer much better compression ratios and speed. It remains available on some systems primarily for compatibility with legacy data and files.
CAVEATS
Obsolescence: pack is largely obsolete and has been replaced by modern compression tools (e.g., gzip, bzip2, xz) due to its inferior compression ratios and generally slower performance.
Single File: It only compresses one file at a time; it does not archive or combine multiple files.
In-place Replacement: The original file is deleted and replaced by its .z version. Always ensure you have backups if the original file is critical.
Limited Options: Offers very few control options for compression level or algorithm, unlike modern compressors.
OUTPUT FILE EXTENSION
Files compressed with pack typically gain a .z extension (e.g., document.txt becomes document.txt.z).
COMPRESSION ALGORITHM
pack employs the Huffman coding algorithm for data compression.
HISTORY
pack was introduced in UNIX Version 7 in the late 1970s, making it one of the earliest standard file compression utilities available on Unix-like systems. It utilized Huffman coding, a then-novel approach for data compression. For many years, it was a common tool for saving disk space, alongside compress.
However, with the advent of more sophisticated and efficient algorithms and the development of tools like gzip (based on DEFLATE) in the early 1990s, pack gradually fell out of favor due to its comparatively poor compression ratio and slower performance on larger files. While still available on some systems for backward compatibility, its practical use has largely ceased.