You are here: >

Linux and Unix uncompress command

uncompress commandAbout uncompress
uncompress syntax
uncompress examples
Related commands
Linux and Unix main page

About uncompress

Uncompresses files that have been compressed using the compress command.


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.

Files compressed with compress typically have the extension .Z, and uncompress looks for and recognizes files with that extension as compressed files.

This utility supports the uncompressing of any files produced by compress. For files produced by compress on other systems, uncompress supports 9- to 16-bit compression (see -b, below).

uncompress syntax

uncompress [-cfv] [file...]


-c Writes to the standard output; no files are changed and no .Z files are created. The behavior of zcat is identical to that of "uncompress -c".
-f When compressing, the -f option forces compression of files, even if it does not actually reduce the size of the files, or if corresponding file.Z files already exist. If the -f option is not given, and the process is not running in the background, prompts to verify whether an existing file.Z file should be overwritten. When uncompressing, does not prompt for overwriting files. If the -f option is not given, and the process is not running in the background, prompts to verify whether an existing file should be overwritten. If the standard input is not a terminal and -f is not given, writes a diagnostic message to standard error and exits with a status greater than 0.
-v Verbose. Writes to standard error any messages concerning the percentage reduction or expansion of each file.
-b bits Sets the upper limit (in bits) for common substring codes. Bits must be between 9 and 16 (16 is the default). Lowering the number of bits will result in larger, less-compressed files.
file A path name of a file to be compressed by compress, uncompressed by uncompress, or whose uncompressed form is written to standard out by zcat. If file is specified as a dash ("-"), or if no file is specified, the standard input will be used.

Exit Status

uncompress returns the following status upon exit:

0 Operation successful.
1 An error occurred.
2 One or more files were not compressed because they would have increased in size (and the -f option was not specified).
>2 An error occurred.

uncompress examples

uncompress myfile.txt.Z

Uncompress the file myfile.txt.Z.

Note that the .Z extension is assumed by default. If intead this command were given as

uncompress myfile.txt

...uncompress would still search for myfile.txt.Z, and uncompress it.

compress — Compress a file or files.
ln — Create a link, or a symbolic link, to a file or directory.
pack — Compress files using a Huffman algorithm.