LinuxCommandLibrary

uncompress

Decompress .Z compressed files

TLDR

Uncompress specific files

$ uncompress [path/to/file1.Z path/to/file2.Z ...]
copy

Uncompress specific files while ignoring non-existent ones
$ uncompress -f [path/to/file1.Z path/to/file2.Z ...]
copy

Write to stdout (no files are changed and no .Z files are created)
$ uncompress -c [path/to/file1.Z path/to/file2.Z ...]
copy

Verbose mode (write to stderr about percentage reduction or expansion)
$ uncompress -v [path/to/file1.Z path/to/file2.Z ...]
copy

SYNOPSIS

uncompress [options] [file ...]

PARAMETERS

-c
    Writes output to standard output, keeping the original compressed file intact.

-f
    Forces decompression. Overwrites an existing output file without prompting, and decompresses files even if they have multiple links.

-v
    Displays verbose output. Shows the decompression ratio and the names of the files being processed.

-q
    Suppresses all warnings and error messages.

-V
    Displays the version number of uncompress (or gzip if it's a symlink).

DESCRIPTION

uncompress is a utility used to decompress files that were previously compressed using the compress command. It specifically handles files with the .Z extension, which signifies the use of the LZW (Lempel-Ziv-Welch) compression algorithm.

When uncompress processes a file like filename.Z, it removes the .Z extension and restores the original filename. By default, it removes the original compressed file upon successful decompression. If the output file already exists, uncompress will prompt for confirmation before overwriting, unless the -f (force) option is used. It can also write the decompressed output to standard output using the -c option, preserving the original compressed file. While uncompress is a standalone command, it is often implemented as a symbolic link to gunzip, which provides broader support for various compression formats, including gzip's own .gz and the older .Z format.

CAVEATS

uncompress is specifically designed for files compressed with the older compress utility, which uses the LZW algorithm, identified by the .Z extension. It does not natively handle other common compression formats like .gz (gzip), .bz2 (bzip2), or .xz (xz), although in many modern systems, uncompress is a symlink to gunzip, which provides broader compatibility.

When decompressing, the original compressed file is deleted by default. Overwriting an existing file without the -f option will prompt the user, which can be problematic in scripts.

DEFAULT BEHAVIOR

By default, uncompress replaces the original compressed file (filename.Z) with the decompressed file (filename) and deletes the .Z version. If no files are specified as arguments, uncompress will read compressed data from standard input and write the decompressed data to standard output.

EXIT STATUS

uncompress typically exits with a status of 0 upon successful completion. A non-zero exit status indicates an error, such as an invalid compressed file or a permission issue.

HISTORY

The compress and uncompress utilities emerged in the early days of Unix, becoming standard tools for file compression. They utilize the LZW (Lempel-Ziv-Welch) algorithm, which was quite efficient for its time.

However, the LZW algorithm became subject to patent disputes, leading to the development of alternative, patent-free compression tools like gzip and gunzip in the early 1990s. gzip offered superior compression ratios and was open-source, quickly superseding compress as the dominant compression utility in the Linux and open-source Unix world.

Today, uncompress is often provided for backward compatibility and is frequently implemented as a symbolic link to gunzip, which can decompress .Z files in addition to its native .gz format.

SEE ALSO

compress(1), gunzip(1), gzip(1), zcat(1), tar(1)

Copied to clipboard