This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Compress" software – news ·newspapers ·books ·scholar ·JSTOR(June 2012) (Learn how and when to remove this message) |
| compress / uncompress | |
|---|---|
| Original author | Spencer Thomas |
| Initial release | February 1985; 41 years ago (1985-02) |
| Operating system | Unix,Unix-like,IBM i |
| Type | Command |
| compress .Z | |
|---|---|
| Filename extension | .Z |
| Internet media type | application/x-compress |
| Developed by | Spencer Thomas |
| Type of format | data compression |
compress is ashellcommand forcompressing data based on theLZW algorithm.[1]uncompress is a companion shell command that restores files to their original state (both content andmetadata) from a file created withcompress.
Although once popular,compress has fallen out of favor because it uses the patented LZW algorithm. Its use has been replaced by commands such asgzip andbzip2 that use other algorithms and provide better data compression. Compared togzip at its fastest setting,compress is slightly slower at compression, slightly faster at decompression, and has a significantly lowercompression ratio.[2] 1.8 MiB of memory is used to compress theHutter Prize data, slightly more thangzip at its slowest setting.[3]
compress anduncompress have maintained a presence onUnix andBSD systems and have been ported toIBM i.[4]
compress was standardized in X/Open CAE Specification in 1994,[5] and further in The Open Group Base Specifications, Issue 6 and 7.[6]Linux Standard Base does not requirecompress.[7]
compress is often excluded from the default installation of aLinux distribution but can be installed from a separate package.[8]compress is available for FreeBSD, OpenBSD, MINIX, Solaris and AIX.
compress is allowed forPoint-to-Point Protocol inRFC 1977 and forHTTP/1.1 inRFC 9110, though it is rarely used in modern deployments as the better deflate/gzip is available.
Files compressed bycompress are typically named withextension ".Z" and therefore sometimes called .Z files. The extension derives from the earlierpack program which used extension ".z".
Mosttar implementations support compression bypiping data throughcompress when given the-Z command line option.
gunzip can decompress .Z files.[9]
The LZW algorithm used incompress was patented bySperry Research Center in 1983.Terry Welch published an IEEE article on the algorithm in 1984,[10] but failed to note that he had applied for a patent on the algorithm. Spencer Thomas of theUniversity of Utah took this article and implementedcompress in 1984, without realizing that a patent was pending on the LZW algorithm. TheGIF image format also incorporated LZW compression in this way, andUnisys later claimed royalties on implementations of GIF. Joseph M. Orost led the team and worked with Thomas et al. to create the final (4.0) version ofcompress and published it as free software to the net.sourcesUSENET group in 1985.U.S. patent 4,558,302 was granted in 1985 – makingcompress unusable without paying royalties to Sperry Research (which later merged into Unisys).
The US LZW patent expired in 2003, so it is now in the public domain in the United States. Today, all LZW patents worldwide are expired (seeGraphics Interchange Format#Unisys and LZW patent enforcement).
As ofPOSIX.1-2024compress supports theDEFLATE algorithm used ingzip.[11]
The compressed output consists of bit groups. Each bit group consists of codes with fixed amount of bits (9–16). Each group, except the last group, is aligned to the number of bits per code multiplied by 8 and right padded with zeroes. The last group is aligned to 8 bit octets and padded with zeroes. More information can be found at an issue on thencompress GitHub repository.[12]
Example:
The existence of padding bits is actually a bug, as LZW does not require any alignment. This bug existed for more than 35 years and was in the original UNIXcompress,ncompress,gzip and the Windows port. Allapplication/x-compress files were created using this bug.
Somecompress implementations write random bits from uninitialized buffer in paddings. There is no guarantee that the paddings will be zeroes. The decompressor must ignore the values in the paddings for compatibility.
Compress is a fast, simple LZW file compressor. Compress does not have the highest compression rate, but it is one of the fastest programs to compress data. Compress is the de facto standard in the UNIX community for compressing files.
compress 4.3d....
compress – Shell and Utilities Reference,The Single UNIX Specification, Version 3 fromThe Open Groupgunzip can currently decompress files created by gzip, zip, compress or pack. The detection of the input format is automatic.
compress: compress data – Shell and Utilities Reference,The Single UNIX Specification, Version 5 fromThe Open Groupcompress(1) – Version 8 Unix Programmer'sManualcompress(1) – FreeBSD General CommandsManualcompress(1) – OpenBSD General CommandsManualcompress(1) – Solaris 11.4 User Commands ReferenceManual