On Unix-like operating systems, the pack command was a file compression program for Unix which used Huffman coding.

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.

Description

pack compresses files using a Huffman minimal redundancy code on a byte basis. Each file is compressed in place; the resulting file has a .z extension appended to the file name, but keeps the same owner and permissions. The times of last access and last modification are also preserved.

  • Description
  • Syntax
  • Exit codes
  • Examples
  • Related commands
  • Linux commands help

Packed files can be identified by file and uncompressed by unpack (which unpacks the file in place) or pcat (which unpacks to the standard output).

Normally pack reports the degree of compression achieved in each file, printing the report to standard output. This number can be negative, especially for small files with little redundancy in their contents, if the -f option is used.

pack does not pack files if:

  • The file appears to have already been packed.
  • The file name is too long (an error occurs if it already has a .z extension).
  • The file has links or is a directory
  • The packed file would be larger than the existing file (this includes empty files).
  • The destination file already exists, or there is an error in processing.

Syntax

pack [[-][-B] [-f] [-o file] file] …

Options

Exit codes

Examples

pack myfile.txt

Packs the file myfile.txt and renames that file to myfile.txt.z. On successful completion, pack will report compression statistics similar to the following:

pack -o out1 in1 -o out2 in2

pack: myfile.txt: -1.8% Compression

cat — Output the contents of a file.compress — Compress a file or files.pcat — Print the uncompressed contents of a compressed file.tar — Create, modify, list the contents of, and extract files from tar archives.unpack — Expand a compressed file.zcat — Print the uncompressed contents of compressed files.