compress

Lempel-Ziv compression of a file 

Command


SYNOPSIS

compress [-cDdfRVv] [-b bits] [-O output_directory] [file ...]


DESCRIPTION

compress compresses each input file using Lempel-Ziv compression techniques. If you do not specify any input files, compress reads data from the standard input and writes the compressed result to the standard output.

On systems using a FAT file system, compress writes compressed output to work files; when the compression finishes successfully, it removes the original files and gives the names of the original files to the work files. In effect, the files are compressed in place. If you want compressed output to go to a different file, use the -c option and redirect output to your chosen file.

On other file systems, output files have the same names as the input files but with a .Z suffix. For example, abc is compressed into abc.Z. The .Z suffix is appended regardless of existing suffixes; for example, abc.txt would be compressed into abc.txt.Z. If the .Z file already exists and you did not specify the -f option, compress gives an error and asks you whether or not it should overwrite the existing file.

compress uses the modified Lempel-Ziv algorithm described in A Technique for High Performance Data Compression, Terry A. Welch, IEEE Computer, vol. 17, no. 6 (June 1984), pp. 8-19. compress first replaces common substrings in the file by 9-bit codes starting at 257. After it reaches code 512, compress begins with 10-bit codes and continues to use more bits until it reaches the limit set by the -b option.

After attaining the bits limit, compress periodically checks the compression ratio. If it is 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. This allows the algorithm to compensate for files, such as archives, where individual components have different information content profiles.

Options

-b bits 

Limits the maximum number of bits of compression to bits. The value bits may be an integer from 9 to 16. The default is 16.

-c 

Writes the output to the standard output. When you use this option, you can only specify one file on the command line.

-D 

Allows an extra degree of compression to be done for files such as sorted dictionaries where subsequent lines normally have many characters in common with the preceding line.

-d 

Decompresses argument files instead of compressing them. This works by overlaying the compress program with the uncompress program. For this to work, uncompress must be available somewhere in your search path (given by the PATH environment variable). Decompressing files this way is slower than calling uncompress directly.

-f 

Forces compression even if the resulting file is larger or the output file already exists. When you do not specify this option, files which are larger after compression are not compressed. compress does not print an error message if this happens.

-O output_directory 

puts the output file in the specified output_directory.

-R 

specifies that the input file is not to be removed.

-V 

Displays the version number of compress.

-v 

Displays statistics giving the amount of compression achieved. Statistics give the name of each file compressed and the compression ratio, expressed as a percentage. If the file resulting from compression is larger than the original, the compression ratio is negative.


ENVIRONMENT VARIABLES

PATH 

Contains a list of directories for compress to search when looking for the uncompress utility.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

Failure because of one of the following errors:

— missing number of bits after -b option
— invalid number of bits specified
— failed to execute uncompress
— unknown option
— dictionary option -- same count of string exceeded
— output path or file name too long
— cannot stat file
— argument file not a regular file: unchanged
— argument file has other links: unchanged
— no space for compression tables
2 

One or more files were not compressed because the compressed version was larger than the original.


LIMITS

This implementation of compress is limited to a maximum of 16 bit compression.


PORTABILITY

Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.

A binary-compatible version of compress with more options is often found on UNIX systems.

The -D option is an extension to traditional implementations of compress. The -D, -d and -V options are extensions to the XPG standard.

For portability, you should restrict the number of bits in the code (-b option) to a value between 9 and 14.


AVAILABILITY

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
bzdiff, bzgrep, bzip2, bzmore, cpio, gzip, mkszip, pax, tar, uncompress, unpack, unzip, zcat, zip, zipinfo

MKS Toolkit Backup and Tape Handling Solutions Guide


PTC MKS Toolkit 10.4 Documentation Build 39.