compress is a
Unix shell
A Unix shell is a Command-line_interface#Command-line_interpreter, command-line interpreter or shell (computing), shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command languag ...
compression program based on the
LZW compression algorithm. Compared to
gzip
gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and ...
's fastest setting, compress is slightly slower at compression, slightly faster at decompression, and has a significantly lower
compression ratio
The compression ratio is the ratio between the maximum and minimum volume during the compression stage of the power cycle in a piston or Wankel engine.
A fundamental specification for such engines, it can be measured in two different ways. Th ...
. 1.8 MiB of memory is used to compress the
Hutter Prize data, slightly more than gzip's slowest setting.
The uncompress utility will restore files to their original state after they have been compressed using the ''compress'' utility. If no files are specified, the
standard input will be uncompressed to the standard output.
Description
Files compressed by ''compress'' are typically given the
extension ".Z" (modeled after the earlier
pack
Pack or packs may refer to:
Music
* Packs (band), a Canadian indie rock band
* ''Packs'' (album), by Your Old Droog
* ''Packs'', a Berner album
Places
* Pack, Styria, defunct Austrian municipality
* Pack, Missouri, United States (US)
* ...
program which used the
extension ".z"). Most ''
tar
Tar is a dark brown or black viscous liquid of hydrocarbons and free carbon, obtained from a wide variety of organic materials through destructive distillation. Tar can be produced from coal, wood, petroleum, or peat. "a dark brown or black b ...
'' programs will
pipe their data through ''compress'' when given the command line option "
-Z
". (The ''tar'' program in its own does not compress; it just stores multiple files within one tape archive.)
Files can be returned to their original state using ''uncompress''. The usual action of ''uncompress'' is not merely to create an uncompressed copy of the file, but also to restore the timestamp and other attributes of the compressed file.
For files produced by ''compress'' on other systems, ''uncompress'' supports 9- to 16-bit compression.
History
The LZW algorithm used in was patented by
Sperry Research Center in 1983.
Terry Welch published an IEEE article on the algorithm in 1984, but failed to note that he had applied for a patent on the algorithm. Spencer Thomas of the
University of Utah
The University of Utah (the U, U of U, or simply Utah) is a public university, public research university in Salt Lake City, Utah, United States. It was established in 1850 as the University of Deseret (Book of Mormon), Deseret by the General A ...
took this article and implemented in 1984, without realizing that a patent was pending on the LZW algorithm. The
GIF
The Graphics Interchange Format (GIF; or , ) is a Raster graphics, bitmap Image file formats, image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released ...
image format also incorporated LZW compression in this way, and
Unisys
Unisys Corporation is a global technology solutions company founded in 1986 and headquartered in Blue Bell, Pennsylvania. The company provides cloud, AI, digital workplace, logistics, and enterprise computing services.
History Founding
Unis ...
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 of and published it as free software to the 'net.sources'
USENET
Usenet (), a portmanteau of User's Network, is a worldwide distributed discussion system available on computers. It was developed from the general-purpose UUCP, Unix-to-Unix Copy (UUCP) dial-up network architecture. Tom Truscott and Jim Elli ...
group in 1985. was granted in 1985, and this is why could not be used without paying royalties to Sperry Research, which was eventually merged into Unisys.
has fallen out of favor in particular user-groups because it makes use of the LZW algorithm, which was covered by a Unisys patentbecause of this,
gzip
gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and ...
and
bzip2
bzip2 is a free and open-source file compression program that uses the Burrows–Wheeler algorithm. It only compresses single files and is not a file archiver. It relies on separate external utilities such as tar for tasks such as handli ...
increased in popularity on
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
-based operating systems due to their alternative algorithms, along with better file compression. ''compress'' has, however, maintained a presence on
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
and
BSD
The Berkeley Software Distribution (BSD), also known as Berkeley Unix or BSD Unix, is a discontinued Unix operating system developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berkeley, beginni ...
systems and the and commands have also been ported to the
IBM i
IBM i (the ''i'' standing for ''integrated'') is an operating system developed by IBM for IBM Power Systems. It was originally released in 1988 as OS/400, as the sole operating system of the IBM AS/400 line of systems. It was renamed to i5/OS in 2 ...
operating system.
The US LZW patent expired in 2003, so it is now in the public domain in the United States. All patents on the LZW worldwide have also expired (see
Graphics Interchange Format#Unisys and LZW patent enforcement).
As of
POSIX.1-2024 ''compress'' supports the
DEFLATE algorithm used in
gzip
gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and ...
.
Special output format
The output binary 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 the ''ncompress'' GitHub repository.
Example:
: Suppose the output has ten 9-bit codes, five 10-bit codes, and thirteen 11-bit codes. There are three groups to output containing 90 bits, 50 bits, and 143 bits of data.
:* First group will be 90 bits of data + 54 zero bits of padding in order to be aligned to 72 bits (9 bits × 8).
:* Second group will be 50 bits of data + 30 zero bits of padding in order to be aligned to 80 bits (10 bits × 8).
:* Third group will be 143 bits of data + 1 zero bit of padding in order to be aligned to 8 bits (since this is the last group in the output).
It is actually a bug. LZW does not require any alignment. This bug existed for more than 35 years and was in the original UNIX ''compress'', ''ncompress'', ''gzip'' and the Windows port. All ''application/x-compress'' files were created using this bug.
Some compress 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.
Standardization and availability
compress was standardized in X/Open CAE Specification in 1994, and further in The Open Group Base Specifications, Issue 6 and 7.
Linux Standard Base
The Linux Standard Base (LSB) was a joint project by several Linux distributions under the organizational structure of the Linux Foundation to standardize the software system structure, including the Filesystem Hierarchy Standard. LSB was based ...
does not requires compress.
compress is often not installed by default in Linux distributions, but can be installed from an additional package. compress is available for FreeBSD, OpenBSD, MINIX, Solaris and AIX.
compress is allowed for
Point-to-Point Protocol
In computer networking, Point-to-Point Protocol (PPP) is a data link layer (layer 2) communication protocol between two routers directly without any host or any other networking in between. It can provide loop detection, authentication, transmissio ...
in and for
HTTP/1.1 in , though it is rarely used in modern deployments as the better deflate/gzip is available.
The gunzip utility is able to decompress .Z files.
See also
*
Data compression
In information theory, data compression, source coding, or bit-rate reduction is the process of encoding information using fewer bits than the original representation. Any particular compression is either lossy or lossless. Lossless compressi ...
*
Image compression
Image compression is a type of data compression applied to digital images, to reduce their cost for computer data storage, storage or data transmission, transmission. Algorithms may take advantage of visual perception and the statistical properti ...
*
List of Unix commands
This is a list of the shell commands of the most recent version of the Portable Operating System Interface (POSIX) IEEE Std 1003.1-2024 which is part of the Single UNIX Specification (SUS). These commands are implemented in many shells on moder ...
*
gzip
gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and ...
References
External links
*
*
*
*
*
ncompress- public domain compress/uncompress implementation for POSIX systems
compress- original Unix compress (in a compress'd archive)
compress- original Unix compress executable (gzip'd)
Source Code for compress v4.0(gzip'd sharchives)
ZIP File containing a Windows port of the compress utilitysource code to the current version of fcompress.c from compressbit groups alignment- Explanation of bit groups alignment.
lzws- New library and CLI, implemented without legacy code.
ruby-lzws- Ruby bindings with streaming support.
{{Archive formats
Data compression software
Unix archivers and compression-related utilities
Standard Unix programs
Unix SUS2008 utilities
IBM i Qshell commands