Expanding compressed files (uncompress and unpack commands)

Use the uncompress and unpack commands to expand compressed files.

Expanding files using the uncompress command

Use the uncompress command to restore original files that were compressed by the compress command. Each compressed file specified by the File variable is removed and replaced by an expanded copy. The expanded file has the same name as the compressed version but without the .Z extension. The expanded file retains the same ownership, modes, and access and modification times as the original file. If no files are specified, standard input is expanded to standard output.

Although similar to the uncompress command, the zcat command always writes the expanded output to standard output.

For example, to uncompress the foo file, type the following:
uncompress foo
Expanding files using the unpack command

Use the unpack command to expand files created by the pack command. For each file specified, the unpack command searches for a file called File.z. If this file is a packed file, the unpack command replaces it with its expanded version. The unpack command renames the new file by removing the .z suffix from File. The new file has the same access modes, access and modification dates, and owner as the original packed file.

The unpack command operates only on files ending in .z. As a result, when you specify a file name that does not end in .z, the unpack command adds the suffix and searches the directory for a file name with that suffix.

The exit value is the number of files that the unpack command was unable to unpack. A file cannot be unpacked if any of the following situations exists:

  • The file name (exclusive of .z) has more than 253 bytes.
  • The file cannot be opened.
  • The file is not a packed file.
  • A file with the unpacked file name already exists.
  • The unpacked file cannot be created.
    Note: The unpack command writes a warning to standard error if the file it is unpacking has links. The new unpacked file has a different i-node (index node) number than the packed file from which it was created. However, any other files linked to the original i-node number of the packed file still exist and are still packed.
For example, to unpack the packed files chap1.z and chap2.z, type the following:
unpack chap1.z chap2
This expands the packed files chap1.z and chap2.z, and replaces them with files named chap1 and chap2.
Note: You can provide the unpack command with file names with or without the .z suffix.