compress
compress
( /usr/bin/compress
) is a packing program for UNIX and UNIX-like operating systems . Its function and behavior are defined in the POSIX standard (and thus also in the Single UNIX Specification and the IEEE 1003.1 standard ). Together with its counterpart ( ), it forms the usual method of storing archives in a space-saving manner.
uncompress
/usr/bin/uncompress
Working method
On systems that do not support the Lempel-Ziv algorithm, compress
the files - passed as arguments - do not change, but rather abort with an error level greater than 2. There is also a termination with an error message if the file extension would cause the maximum name length specified .Z
by the kernel constant to NAME_MAX
be exceeded.
On all other systems, the files are packed and replaced by the packed file, the name of which is extended by an appended .Z
. If the authorization of the executing process is sufficient, authorizations and owners are retained. These files can be extracted again with the program uncompress
( /usr/bin/uncompress
), whereby uncompress
the appended file extension .Z
is removed again.
Like gzip
and only bzip2
compresses compress
individual files. If multiple files or even entire directory hierarchies are combined, it is typically (with an archiving program tar
, cpio
, backup
etc.) are used together, the output of which can then be compressed.
Patent law considerations
The POSIX standard specifies that compress
files are processed according to the adaptive Lempel-Ziv algorithm (also: LZC, a variant of the LZW algorithm). This algorithm (more precisely: the underlying algorithm LZ78 ) as well as its extension by Terry A. Welch was protected by US patents until 2003 (in Japan until 2004), which were issued to the Sperry Corporation .
Alternatives
This dependence on a proprietary method was one of the reasons for the development of alternatives gzip
as well bzip2
, both of which are based on similar, but public domain, compression methods with variable pointers. The GNU operating system therefore uses gzip
(GNU-zip) as a replacement for compress
. gzip
can compress
read and unpack the files generated with , but compression is not supported due to the (formerly) patented process used for this purpose.
Notes on use, examples
Usually takes compress
one or more file names as an argument and replaces these files with their compressed version directly in the file system. With the switch -c
, the compressed version is stdout
output instead and the file system content is not changed. On the one hand, this can be used to store compressed backups on all kinds of external devices (tape drives, etc.) (the data stream is then made available to a suitable driver program via a pipeline ), or to avoid the otherwise necessary deletion of the output files:
# compress -c /path/to/input > /path/to/output.Z
The switch also offers the option of influencing the compression (rate): N is the maximum number of bits to be used for a code (values between 9 and 14 are supported). Longer codes enable better compression with a simultaneous increase in computing effort.
-c N
Individual evidence
- ↑ compress specification of the Open Group. Retrieved May 12, 2013 .
- ↑ US Patent No. 4464650. Retrieved May 12, 2013 (English).
- ↑ US Patent No. 4558302. Retrieved May 12, 2013 (English).