COMPRESS(1)

πŸ“¦
version 5.0 Β· 3 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

okay so bestie, you're looking at the General Commands Manual page for compress and uncompress.real, and it's literally the blueprint for squishing your files down small and then popping them right back. main character compression energy, no cap. πŸ¦‹βœ¨

✨ NAME ✨

compress, uncompress.real β€” compress and expand data πŸ’…

πŸŽ€ SYNOPSIS πŸŽ€

compress [ -f ] [ -k ] [ -v ] [ -c ] [ -V ] [ -r ] [ -b bits ] [ -- ] [ name ... ]
uncompress.real [ -f ] [ -k ] [ -v ] [ -c ] [ -V ] [ -- ] [ name ... ]

πŸ’– DESCRIPTION πŸ’–

okay first things first, and this is important: the program that would normally be installed as uncompress is installed on Debian as uncompress.real. why? because otherwise it would beef with the way more commonly used program that has the exact same name and lives inside the gzip package. so yeah, .real it is. periodt. πŸ™ˆ

compress reduces the size of the named files using adaptive Lempel-Ziv coding. whenever possible, each file gets replaced by one with the extension .Z, while keeping the same ownership modes, access and modification times. the way it keeps your metadata? iconic. πŸ‘‘

  • if no files are specified, the standard input gets compressed to the standard output. 🫢
  • compress will only even attempt to compress regular files. in particular, it will ignore symbolic links, like, completely.
  • if a file has multiple hard links, compress will refuse to compress it unless the -f flag is given. it's not being dramatic, it just doesn't wanna break your links fr fr.

if -f is not given and compress is run in the foreground, the user gets prompted about whether an existing file should be overwritten. bestie gets a say. πŸ’…

compressed files can be restored to their original form using uncompress.real. it 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. glow-up, but make it metadata. ✨

now the flags, quick tour:

  • -k β€” makes compress/uncompress keep the input files instead of automatically removing them. hoarder mode, but respectful.
  • -c β€” makes compress/uncompress.real write to the standard output; no files are changed. it's giving "look but don't touch."
  • -r β€” if this 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 in there. when compressing, any files that are already compressed get ignored; when decompressing, any files that are already decompressed get ignored. it knows when to not do too much. πŸ’€
  • -V β€” 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. πŸ“œ

🌈 the algorithm bit (iykyk) 🌈

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. πŸ“š

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. tiny machine rights! 🧚

after the bits limit is attained, compress periodically checks the compression ratio. if it's increasing, compress continues to use the existing code dictionary. however, if the compression ratio decreases, compress discards the table of substrings and rebuilds it from scratch. dramatic? no. adaptive. this allows the algorithm to adapt to the next "block" of the file. it's literally reinventing itself every era. πŸ”₯

note that the -b flag is omitted for uncompress.real, 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. the file tells you what it needs. self-aware king. πŸ‘‘

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. not to compare but like... it ate. πŸ’…

under the -v option, a message is printed yielding the percentage of reduction for each file compressed. πŸ“‰

-- may be used to halt option parsing and force all remaining arguments to be treated as paths. so if a filename is out here looking like a flag, you can shut that down. πŸ›‘

πŸ’€ 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.

here's every message and what it's actually telling you, bestie:

  • Usage: compress [-dfvcVr] [-b maxbits] [file ...] β€” invalid options were specified on the command line. πŸ™ˆ
  • Missing maxbits β€” maxbits must follow -b.
  • file: not in compressed format β€” the file specified to uncompress.real has not been compressed.
  • file: compressed with xx bits, can only handle yy bits β€” the 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.
  • 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. (so if you're not on BSD and your name is too long... yeah. βœ‚οΈ)
  • 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.
  • uncompress.real: corrupt input β€” a SIGSEGV violation was detected, which usually means that the input file has been corrupted. 😭
  • 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.
  • -- 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. πŸ’…

πŸ› 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 (64 KiB or less, as exhibited by the DEC PDP series, the Intel 80286, etc.) β€” so like, know your audience before you send the file. 🫢

🌸 SEE ALSO 🌸

pack(1), compact(1)


and that's the whole page, bestie!! this one comes to you from ncompress, dated 2024-05-21 β€” go compress something and hydrate. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from