The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


pack - compress files (LEGACY)


pack [-f][-] file...


The pack utility attempts to store the specified files in a compressed form. Each input file is replaced by a packed file file.z. If the invoking process has appropriate privileges, the ownership, modes, access time, and modification time of the original file are preserved. If pack is successful, file will be removed. Packed files can be restored to their original form using unpack or pcat.

No packing will occur if:

The last segment of the filename must contain no more than {NAME_MAX}-2 bytes to allow space for the appended .z extension.


The pack utility supports the XBD specification, Utility Syntax Guidelines  . The following option is supported:

Force packing of files. This is useful for causing an entire directory to be packed even if some of the files will not benefit.


The following operands are supported:
Sets an internal flag that causes the number of times each byte is used, its relative frequency and the code for the byte to be written to standard output. Additional occurrences of - in place of file will cause the internal flag to be set and reset.
A pathname of a file to be packed; file can include or omit the .z suffix.


Not used.


The input files are regular files.


The following environment variables may affect the execution of pack:
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
If set to a non-empty string value, override the values of all the other internationalisation variables.
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error, and informative messages written to standard output.
Determine the location of message catalogues for the processing of LC_MESSAGES .


If an error or signal occurs, the file.z file is not created and the original file is unchanged.


The standard output is a text file containing one line for each file packed, with the following format used in the POSIX locale:

"pack: %s: %2.1f%% Compression\n", file, <percent compression> or:

"pack: %s: no saving - file unchanged\n", file

If the - operand is specified and the internal flag is set, additional messages of unspecified format will be written to standard output as indicated in the OPERANDS section.


Used only for diagnostic messages.


Packed files of unspecified format are created with names of the form file.z.




The following exit values are returned:
Successful completion.
An error occurred.




The amount of compression obtained depends on the size of the input file and the character frequency distribution. Because a decoding tree may form the first part of each .z file, it is usually not worthwhile to pack small files, unless the character frequency distribution is very skewed, which may occur with printer plots or pictures.

Typically, text files are reduced to 60-75% of their original size. Object files, which use a larger character set and have a more uniform distribution of characters, show little compression, the packed versions typically being about 90% of the original size.

Packed files are not necessarily portable to other systems.

Applications should migrate to the compress utility. The compress utility offers two advantages over pack:






pcat, unpack, compress.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]