Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Compress (software)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Unix shell compression program based on the LZW compression algorithm}} {{redirect|compress|the cloth used in medicine|Compress (medical)|other uses|Compression (disambiguation)}} {{More citations needed|date=June 2012}} {{lowercase title}} {{Infobox software | name = compress / uncompress | logo = | screenshot = | screenshot size = | caption = | author = Spencer Thomas | developer = | released = {{Start date and age|1985|2}} | latest release version = | latest release date = | operating system = [[Unix]], [[Unix-like]], [[IBM i]] | genre = [[Command (computing)|Command]] | license = | website = }} {{Infobox file format | name = compress .Z | extension = .Z | mime = application/x-compress | owner = Spencer Thomas | genre = [[data compression]] | website = }} '''compress''' is a [[Unix shell]] [[compression program]] based on the [[LZW]] compression algorithm.<ref>{{cite web |url=http://ncompress.sourceforge.net/ |title=ncompress: a public domain project |last=Frysinger |first=Mike |access-date=2014-07-30 |quote=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. }}</ref> Compared to [[gzip]]'s fastest setting, compress is slightly slower at compression, slightly faster at decompression, and has a significantly lower [[Data compression ratio|compression ratio]].<ref>{{cite web |first=Luc|last=Gommans|title=compression - What's the difference between gzip and compress? |url=https://unix.stackexchange.com/a/412573 |website=Unix & Linux Stack Exchange |language=en}}</ref> 1.8 MiB of memory is used to compress the [[Hutter Prize]] data, slightly more than gzip's slowest setting.<ref>{{cite web |title=Large Text Compression Benchmark |url=http://mattmahoney.net/dc/text.html |website=mattmahoney.net |quote=compress 4.3d....}}</ref> 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 [[filename extension|extension]] ".Z" (modeled after the earlier [[pack (compression)|pack]] program which used the [[filename extension|extension]] ".z"). Most ''[[tar (file format)|tar]]'' programs will [[pipe (Unix)|pipe]] their data through ''compress'' when given the command line option "<code>-Z</code>". (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 {{Mono|compress}} was patented by [[Sperry Corporation|Sperry Research Center]] in 1983. [[Terry Welch]] published an IEEE article on the algorithm in 1984,<ref>{{cite journal|author=Welch, Terry A.|author-link=Terry Welch|url=https://www.cs.duke.edu/courses/spring03/cps296.5/papers/welch_1984_technique_for.pdf|title=A technique for high performance data compression|journal=IEEE Computer|volume=17|issue=6|pages=8β19|year=1984|doi=10.1109/MC.1984.1659158|s2cid=2055321 }}</ref> but failed to note that he had applied for a patent on the algorithm. Spencer Thomas of the [[University of Utah]] took this article and implemented {{Mono|compress}} in 1984, without realizing that a patent was pending on the LZW algorithm. The [[Graphics Interchange Format|GIF]] image format also incorporated LZW compression in this way, and [[Unisys]] 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 {{Mono|compress}} and published it as free software to the 'net.sources' [[USENET]] group in 1985. {{US patent|4558302}} was granted in 1985, and this is why {{Mono|compress}} could not be used without paying royalties to Sperry Research, which was eventually merged into Unisys. {{Mono|compress}} has fallen out of favor in particular user-groups because it makes use of the LZW algorithm, which was covered by a Unisys patent{{snd}}because of this, [[gzip]] and [[bzip2]] increased in popularity on [[Linux]]-based operating systems due to their alternative algorithms, along with better file compression. ''compress'' has, however, maintained a presence on [[Unix]] and [[BSD]] systems and the {{Mono|compress}} and {{Mono|uncompress}} commands have also been ported to the [[IBM i]] operating system.<ref>{{cite web |title=IBM System i Version 7.2 Programming Qshell |language=en |author=IBM |website=[[IBM]] |author-link=IBM |url=https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahz/rzahzpdf.pdf?view=kc |access-date=2020-09-05 }}</ref> 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#POSIX.1-2024|POSIX.1-2024]] ''compress'' supports the [[DEFLATE]] algorithm used in [[gzip]].<ref>{{cite web |title=compress |url=https://pubs.opengroup.org/onlinepubs/9799919799/utilities/compress.html |publisher=opengroup |access-date=2 November 2024}}</ref> == 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.<ref>{{Cite web |title=compression with 9 bits don't work Β· Issue #5 Β· vapier/ncompress |url=https://github.com/vapier/ncompress/issues/5 |access-date=2024-09-17 |website=GitHub |language=en}}</ref> 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{{What|date=September 2024}} 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.<!--What is "specification" here?: So we have to include it in output specification.--> 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,<ref>[https://pubs.opengroup.org/onlinepubs/009656399/toc.pdf X/Open CAE Specification Commands and Utilities Issue 4, Version 2] (pdf), 1994, opengroup.org</ref> and further in The Open Group Base Specifications, Issue 6 and 7.<ref>{{man|cu|compress|SUS6}}</ref> [[Linux Standard Base]] does not requires compress.<ref>[https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/command.html Chapter 17. Commands and Utilities] in Linux Standard Base Core Specification 5.0.0, linuxfoundation.org</ref> compress is often not installed by default in Linux distributions, but can be installed from an additional package.<ref>[https://pkgs.org/download/ncompress ncompress], pkgs.org</ref> compress is available for FreeBSD, OpenBSD, MINIX, Solaris and AIX. compress is allowed for [[Point-to-Point Protocol]] in {{IETF RFC|1977}} and for [[HTTP/1.1]] in {{IETF RFC|9110}}, though it is rarely used in modern deployments as the better deflate/gzip is available. The gunzip utility is able to decompress .Z files.<ref>{{cite web | title=GNU Gzip | website=The GNU Operating System and the Free Software Movement | date=2023-02-05 | url=https://www.gnu.org/software/gzip/manual/gzip.html | access-date=2024-04-03 |quote=gunzip can currently decompress files created by gzip, zip, compress or pack. The detection of the input format is automatic. }}</ref> == See also == * [[Data compression]] * [[Image compression]] * [[List of Unix commands]] * [[gzip]] == References == {{Reflist}} == External links == * {{man|cu|compress|SUS|compress data}} * {{man|1|compress|v8}} * {{man|1|compress|FreeBSD}} * {{man|1|compress|OpenBSD}} * {{man|1|compress|Solaris}} * [http://ncompress.sourceforge.net/ ncompress] - public domain compress/uncompress implementation for POSIX systems * [http://ibiblio.org/pub/linux/utils/compress/compress.tar.Z compress] - original Unix compress (in a compress'd archive) * [http://ibiblio.org/pub/linux/utils/compress/compress.z compress] - original Unix compress executable (gzip'd) * [http://ftp.sunet.se/mirror/archive/ftp.sunet.se/pub/usenet/ftp.uu.net/comp.sources.unix/volume2/compress4.0/ Source Code for compress v4.0] (gzip'd sharchives) * [http://www.willus.com/archive/unixcmds.zip ZIP File containing a Windows port of the compress utility] * [https://svnweb.freebsd.org/base/head/usr.bin/compress/ source code to the current version of fcompress.c from compress] * [https://github.com/vapier/ncompress/issues/5 bit groups alignment] - Explanation of bit groups alignment. * [https://github.com/andrew-aladev/lzws lzws] - New library and CLI, implemented without legacy code. * [https://github.com/andrew-aladev/ruby-lzws ruby-lzws] - Ruby bindings with streaming support. {{Compression Software Implementations}}{{Archive formats}} [[Category:Data compression software]] [[Category:Unix archivers and compression-related utilities]] [[Category:Standard Unix programs]] [[Category:Unix SUS2008 utilities]] [[Category:IBM i Qshell commands]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Archive formats
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite web
(
edit
)
Template:Compression Software Implementations
(
edit
)
Template:IETF RFC
(
edit
)
Template:Infobox file format
(
edit
)
Template:Infobox software
(
edit
)
Template:Lowercase title
(
edit
)
Template:Man
(
edit
)
Template:Mono
(
edit
)
Template:More citations needed
(
edit
)
Template:Redirect
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Snd
(
edit
)
Template:US patent
(
edit
)
Template:What
(
edit
)