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 -b and walk away, bestie
  • file: not in compressed format โ€” the file specified to uncompress has 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 the compress code 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 than 12 characters. rename and try again. this message does not occur on BSD systems. name too long, sorry queen
  • file 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 โ€” a SIGSEGV violation 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. see ln(1) for more information. use the -f flag 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