pack — Compress files by Huffman coding

Format

Start of changepack [] [–Bf] [–o file] file End of change

The pack utility is fully supported for compatibility with older UNIX systems. However, the compress utility should be used instead because it may provide greater functionality and is considered the standard for portable UNIX applications as defined by POSIX.2 IEEE standard 1003.2-1992.

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. For example, abc is compressed into abc.z. The times of last access and last modification are also preserved.

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 (the report is printed on stdout). This number can be negative for small files with little redundancy 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 .z is appended.
  • 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.

Options

Displays more detail on size, overhead and entropy (information rate). If this option is used several times on the command line. it acts as a toggle, inverting the detailed-report flag at each mention.
-B
Start of changeDisables the automatic conversion of tagged files.End of change
–f
Forces compression when it typically would not occur. Without this option, pack does not compress a file if its size is not reduced by compression, the file is already compressed, or the file has more than one link.
–o file
Specifies a different output file so that compressed output is written to file rather than overwriting the original input file. Several input and output files may be specified. For example,
pack –o out1 in1 –o out2 in2
packs file in1 into out1 and file in2 into out2. The input files are not changed.

Localization

pack uses the following localization environment variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • NLSPATH

See Localization for more information.

Start of change

Environment variables

pack uses the following environment variable:
_TEXT_CONV
Contains text conversion information for the command. The text conversion information is not used when the -B option is specified. For more information about text conversion, see Controlling text conversion for z/OS UNIX shell commands.
End of change

Exit values

0
Successful completion
1
An error occurred due to one of the following:
  • A problem related to manipulating (opening, closing, renaming) the file, or a single file could not be packed properly
  • Start of changeCould not turn off automatic conversionEnd of change
n
Indicates that n files could not be packed properly. For example, if three out of six files could not be packed properly, the exit status is 3.
file: no saving
The file is too small or uniform to benefit from packing. The file can still be packed using the –f option.
file: already packed
The file appears to be a packed file. It can still be packed by specifying the –f option.
file: has links
The file has more than one link. You can override it with the –f option.
file: directory
pack cannot modify directories.
file: empty
The file is empty.
file: can't pack in place
The file is too large to pack in place. Use the –o option to specify an output file.
Interrupt
If you press BREAK while pack is running, it does not stop immediately; if it did, it would leave you with a corrupted file. Thus pack just displays this message to show that the BREAK has been received and it stops as soon as it is safe to do so.

Other messages, such as those about inaccessibility of files, are self-explanatory. The exit status is the number of file arguments that could not be processed.

Portability

X/Open Portability Guide, UNIX System V.

Start of changeThe –B and –o options are extensions of the POSIX standard.End of change

Related information

file, pcat, unpack