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 file appears to be already packed.
- The filename has more than {NAME_MAX}-2 bytes.
- The file has links.
- The file is a directory.
- The file cannot be opened.
- The file is empty.
- No disk storage will be saved by packing.
- A file called file.z already exists.
- The .z file cannot be created.
- An I/O error occurred during processing.
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:
- -f
- 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.
- file
- 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:
- LANG
- 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.
- LC_ALL
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- LC_CTYPE
- 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).
- LC_MESSAGES
- 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.
- NLSPATH
- 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.
None.
The following exit values are returned:
- 0
- Successful completion.
- >0
- An error occurred.
Default.
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:
- The algorithm used to create the output files is frequently more effective in reducing the sizes of files.
- The compress utility can compress data from its standard input, not just a named regular file. Thus, it is useful in pipelines.
None.
None.
pcat, unpack, compress.