COMPRESS(1)
๐ COMPRESS ๐
okay so bestie, welcome to the compress page, straight outta the General Commands Manual ๐
this is the whole trio โ compress, uncompress and zcat โ and no cap, they're the friend group that squishes your files down and puffs them back up. sit down, grab a strawberry ๐, we're doing this properly.
โจ NAME โจ
compress, uncompress, zcat โ compress and expand data ๐
๐ SYNOPSIS ๐
compress [ -f ] [ -k ] [ -v ] [ -c ] [ -V ] [ -r ] [ -b bits ] [ -- ] [ name ...
]
uncompress [ -f ] [ -k ] [ -v ] [ -c ] [ -V ] [ -- ] [ name ... ]
zcat [ -V ] [ -- ] [ name ... ]
๐ฆ DESCRIPTION ๐ฆ
compress shrinks the named files using adaptive Lempel-Ziv coding, and it's genuinely so good at it. whenever it can, every file gets swapped out for one with the extension .Z, and it keeps the same ownership modes, access times and modification times โ it's giving considerate icon behaviour ๐ซถ
if you don't name any files, then standard input gets compressed to standard output. simple as that, no drama.
compress will only attempt to compress regular files. in particular, it will ignore symbolic links โ it's literally not the vibe. and if a file has multiple hard links, compress will refuse to compress it unless you hand it the -f flag.
if -f is not given and compress is running in the foreground, the user gets prompted about whether an existing file should be overwritten. be ready to answer, bestie, it's waiting on you ๐
compressed files can be restored to their original form using uncompress or zcat ๐
uncompress takes a list of files on its command line and replaces each file whose name ends with .Z and which begins with the correct magic number with an uncompressed file without the .Z. the uncompressed file will have the mode, ownership and timestamps of the compressed file. magic numbers are basically the receipts, iykyk ๐ง
the -k option makes compress/uncompress keep the input files instead of automatically removing them. keeping the source file? main character energy, honestly โจ
the -c option makes compress/uncompress write to the standard output; no files are changed.
zcat is identical to uncompress -c. it uncompresses either a list of files on the command line or its standard input and writes the uncompressed data on standard output. zcat will uncompress files that have the correct magic number whether they have a .Z suffix or not โ suffix? never heard of her ๐
if the -r flag is specified, compress will operate recursively. if any of the file names specified on the command line are directories, compress will descend into the directory and compress all the files it finds there. when compressing, any files already compressed will be ignored, and when decompressing, any files already decompressed will be ignored. it's thorough, not nosy ๐
the -V flag tells each of these programs to print its version and patchlevel, along with any preprocessor flags specified during compilation, on stderr before doing any compression or uncompression. receipts first, work second ๐
compress uses the modified Lempel-Ziv algorithm popularized in "A Technique for High Performance Data Compression", Terry A. Welch, IEEE Computer, vol. 17, no. 6 (June 1984), pp. 8-19. we stan a cited queen ๐
the way it works: common substrings in the file are first replaced by 9-bit codes 257 and up. when code 512 is reached, the algorithm switches to 10-bit codes and continues to use more bits until the limit specified by the -b flag is reached (default 16). bits must be between 9 and 16. the default can be changed in the source to allow compress to be run on a smaller machine. scalable AND humble ๐ฆ
after the bits limit is attained, compress periodically checks the compression ratio. if it's increasing, compress continues to use the existing code dictionary. but if the compression ratio decreases, compress discards the table of substrings and rebuilds it from scratch. this allows the algorithm to adapt to the next "block" of the file โ glowing up, block by block โจ
note that the -b flag is omitted for uncompress, since the bits parameter specified during compression is encoded within the output, along with a magic number to ensure that neither decompression of random data nor recompression of compressed data is attempted. it knows what it is, it doesn't need you to tell it ๐
the amount of compression obtained depends on the size of the input, the number of bits per code, and the distribution of common substrings. typically, text such as source code or English is reduced by 50-60%. compression is generally much better than that achieved by Huffman coding (as used in pack), or adaptive Huffman coding (compact), and takes less time to compute. better AND faster?? ate, no crumbs ๐ญ๐ฅ
under the -v option, a message is printed yielding the percentage of reduction for each file compressed. numbers! we love numbers! ๐
-- may be used to halt option parsing and force all remaining arguments to be treated as paths. the "okay we're done with flags now" move ๐ซถ
๐ DIAGNOSTICS ๐
exit status is normally 0; if the last file is larger after (attempted) compression, the status is 2; if an error occurs, exit status is 1. three moods, three numbers
Usage: compress [-dfvcVr] [-b maxbits] [file ...]โ invalid options were specified on the command line. typo era, be so for real ๐ญMissing maxbitsโ maxbits must follow-b. you can't just say-band walk away, bestiefile: not in compressed formatโ the file specified touncompresshas not been compressed.file: compressed with xx bits, can only handle yy bitsโ file was compressed by a program that could deal with more bits than thecompresscode on this machine. recompress the file with smaller bits. this machine said "I can't even"file: already has .Z suffix -- no changeโ the file is assumed to be already compressed. rename the file and try again.file: filename too long to tack on .Zโ the file cannot be compressed because its name is longer than12characters. rename and try again. this message does not occur on BSD systems. name too long, sorry queenfile already exists; do you wish to overwrite (y or n)?โ respond"y"if you want the output file to be replaced;"n"if not. this is your moment, choose wisely ๐uncompress: corrupt inputโ aSIGSEGVviolation was detected which usually means that the input file has been corrupted. bestie that file is NOT okay ๐Compression: xx.xx%โ percentage of the input saved by compression. (relevant only for-v.)-- not a regular file or directory: ignoredโ when the input file is not a regular file or directory, (e.g. a symbolic link, socket, FIFO, device file), it is left unaltered. not it, not touching it-- has xx other links: unchangedโ the input file has links; it is left unchanged. seeln(1)for more information. use the-fflag to force compression of multiply-linked files.-- file unchangedโ no savings is achieved by compression. the input remains virgin. respectfully untouched โจ
๐ BUGS ๐
although compressed files are compatible between machines with large memory, -b12 should be used for file transfer to architectures with a small process data space (64KB or less, as exhibited by the DEC PDP series, the Intel 80286, etc.) old hardware, we still love you ๐ซถ
lowkey important though โ if you're yeeting files at a tiny-memory machine, use -b12. fr fr.
๐ SEE ALSO ๐
pack(1), compact(1) โ the extended universe ๐
and that's the whole page, bestie!! this one came from the local source, and it's signed off as COMPRESS(1) at the bottom โ so you know exactly which page you're reading ๐ go forth and squish some data, you've got this ๐๐
โจ
๐ฆ where this page comes from
- arch rolling: ncompress 5.0-3 ยท custom:PublicDomain
- epel 10: ncompress 5.0-7.el10_0 ยท Unlicense
- epel 9: ncompress 5.0-3.el9 ยท Public Domain
- fedora 43: ncompress 5.0-10.fc43 ยท Unlicense
- fedora 44: ncompress 5.0-11.fc44 ยท Unlicense
- nixos 26.05: ncompress 5.0
- nixpkgs unstable: ncompress 5.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms