Linux unpack command

Updated: 05/04/2019 by Computer Hope
unpack command

On Unix-like operating systems, the unpack was the utility used to expand a file that was compressed with the pack utility. It is documented here for historical reasons.

Note

The pack and unpack utilities are no longer used on modern systems. If you need to work with files compressed with pack, use the gzip utility, which can automatically detect and decompress files that use pack compression.

Syntax

unpack file

Description

The unpack command expands files created by pack. For each file specified in the command, a search is made for a file called file.z (or file, if file ends in .z). If this file appears to be a packed file, it is replaced by its expanded version. The new file has the .z suffix stripped from its name, and has the same access modes, access and modification dates, and owner as those of the packed file.

unpack returns a value that is the number of files it was unable to unpack. Failure may occur for the same reasons that it may in pcat, and for the following:

  • a file with the "unpacked" name already exists;
  • the unpacked file cannot be created;
  • the file name (excluding the .z extension) has more than 14 bytes. (this shows you how antiquated unpack is!)

Examples

unpack myfile.txt.z

Unpack the file myfile.txt.z into the file myfile.txt.

cat — Output the contents of a file.
compress — Compress a file or files.
pack — Compress files using a Huffman algorithm.
pcat — Print the uncompressed contents of a compressed file.
zcat — Print the uncompressed contents of compressed files.