pack(1) pack(1)
NAME
pack - compress files
SYNOPSIS
pack [-f] [--] [-] file...
DESCRIPTION
pack compresses files using Huffman coding.
On systems which evaluate the RSTCHOWN variable, the user who invokes
pack is made the owner of the packed file (unless the invoking user is
the system administrator). On other systems the owner stays the same.
The access permissions and the dates of last access and modification
stay the same.
Where possible, each file is replaced by a file with the same basename
plus a .z extension.
The amount of compression obtained depends on the size of the input
file and the character frequency distribution. Typically, text files
are reduced to 60-75% of their original size.
Since a decoding tree forms the first part of a packed file, it is
usually not worthwhile to pack small files, unless the character fre-
quency distribution is very skewed, which may occur with printer plots
or pictures. Object files, which use a larger character set and have a
more uniform distribution of characters, show little compression, the
packed versions being about 90% of the original size.
No packing will occur if
- the file to be compressed is not a regular file
- there are links to the file to be compressed
- the file to be compressed already has a .z extension
- the file to be created already exists
- no storage space is saved as a result of compression.
You can use unpack to restore packed files to their original form.
pcat writes packed files in their original form to standard output
without modifying the packed file.
Note: You can also compress files using compress and uncompress then
using uncompress.
Page 1 Reliant UNIX 5.44 Printed 11/98
pack(1) pack(1)
OPTIONS
No option specified:
The files specified are compressed if storage space can be saved
as a result. The percentage of compression for each packed file
is displayed.
-f (f - force) Forces file to be compressed even though no storage
space will be saved.
-f not specified:
Only the files for which storage space can be saved are
compressed.
-- End of the list of options. Must be specified if file begins with
- and the argument - is not specified.
- Causes detailed statistical information on the completed compres-
sion to be written to standard output:
pack: file: xx.xx% Compression
Percentage of compression
pack: From xxxxx to yyyyy bytes
Old size versus new size
Huffman tree has xx levels below root
Depth of the tree processed with the Huffman algorithm
xx distinct bytes in input
Number of distinct bytes in file
Dictionary overhead = xxx bytes
Size of decoding rules
Effective entropy = x.xx bits/byte
Actual reduction factor
Asymptotic entropy = x.xx bits/byte
Theoretical reduction factor
A line containing the following information is output for each
character that appears in the input file:
Byte xxxx
Octal value of the character
Count = xx
Total number of these characters in the file
Page 2 Reliant UNIX 5.44 Printed 11/98
pack(1) pack(1)
Relative freq. = x.xxx
Relative proportion of these characters to the file size in
percent
Code = xxxxx
Specifies how the character was coded
- is not an option, but an argument, and must therefore not be
placed before the -f option. - can be specified before each file
and/or before several files in sequence. Every second occurrence
of - switches off the output of statistical information again
(see Example 1).
- not specified: The percentage of compression is printed.
file Name of the file to be compressed. You may specify more than one
file.
file must not be a directory and there must be no other links to
it.
The packed file is given the name file.z; the original file is
deleted after successful compression. file.z has the same access
permissions and the same access and modification times as file.
The maximum length of the name of file is equal to the maximum
file name length supported by the file system, minus 2 charac-
ters. This allows for the extension to file.z. If this length is
exceeded, file will not be compressed.
file can also be specified as file.z. The suffix .z is ignored by
pack.
Caution: Packed files are not necessarily portable to other sys-
tems.
Make sure that the other system has the same character
set loaded and has the unpack command available on it.
ERROR MESSAGES
pack: file: no saving - file unchanged
(printed to standard output) No storage space can be saved by
compression. Compression does not take place. If you wish, you
can force the compression with the -f option.
pack: file: file name too long
The name of the file to be packed is too long. Compression does
not take place.
Page 3 Reliant UNIX 5.44 Printed 11/98
pack(1) pack(1)
pack: file.z: already packed
The file specified has already been compressed. It cannot be
compressed a second time.
pack: file: has links
There are links to the files to be compressed. Compression does
not take place.
pack: file: cannot pack a directory
The specified file is a directory. Compression does not take
place.
pack: file: cannot open
You have no read permission for the file to be packed, or file
does not exist.
pack: file.z: cannot create
The packed file cannot be created, e.g. because you have no write
permission for the current directory.
pack: file: read error
An error occurred when reading the original file. Compression
does not take place.
pack: file.z: write error
An error occurred when writing the packed file. The compression
is aborted, and file remains unchanged. It is possible that an
incomplete file.z is now present on the system.
pack: file: cannot pack a zero length file
The file to be packed is empty.
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed. If LCMESSAGES is undefined or is defined
as the null string, it defaults to the value of LANG. If LANG is like-
wise undefined or null, the system acts as if it were not internation-
alized.
The LCALL environment variable governs the entire locale. LCALL
takes precedence over all the other environment variables which affect
internationalization.
Page 4 Reliant UNIX 5.44 Printed 11/98
pack(1) pack(1)
EXAMPLES
Example 1
Three files are to be compressed. Statistical information on the
compression is to be displayed for the first two files, but not for
the third. Since the second and subsequent occurrences of the - option
serve as toggles, the option must be specified again before file3 to
turn off the statistics function:
$ pack - file1 file2 - file3
pack: file1: 40.6% Compression
pack: From 31960 to 18984 bytes
Huffman tree has 15 levels below root
89 distinct bytes in input
Dictionary overhead = 111 bytes
Effective entropy = 4.75 bits/byte
Asymptotic entropy = 4.72 bits/byte
Byte 0000, Count = 45211, Relative freq. = 0.311, Code = 11
Byte 0001, Count = 2530, Relative freq. = 0.017, \
Code = 100000
...
Byte 0377, Count = 2018, Relative freq. = 0.014, \
Code = 101001
pack: file2: 41.6% Compression
pack: From 249569 to 145840 bytes
Huffman tree has 14 levels below root
94 distinct bytes in input
Dictionary overhead = 115 bytes
Effective entropy = 4.67 bits/byte
Asymptotic entropy = 4.67 bits/byte
Byte 0000, Count = 96281, Relative freq. = 0.323, Code = 11
Byte 0001, Count = 5225, Relative freq. = 0.018, \
Code = 011100
...
Byte 0377, Count = 4644, Relative freq. = 0.016, \
Code = 101001
pack: file3: 41.7% Compression
Page 5 Reliant UNIX 5.44 Printed 11/98
pack(1) pack(1)
Example 2
All files contained in the directory GMC3 are to be compressed. The
file print in this directory does not, however, have any read permis-
sions set, and the file user.new is empty. These files are therefore
retained in their original state.
$ ls -l GMC3
total 272
-rw-r--r-- 1 naomi gmc3 117865 Aug 19 09:27 data80-90
---x--x--x 1 naomi gmc3 5366 Mar 15 12:50 print
-rw-r--r-- 1 naomi gmc3 1447 Jan 10 17:02 user.old
-rw-r--r-- 1 naomi gmc3 0 Mar 14 13:16 user.new
$ pack -f GMC3/*
pack: GMC3/data80-90: 39.5% Compression
pack: GMC3/print: cannot open
pack: GMC3/user.old: 37.9% Compression
pack: GMC3/user.new: cannot pack a zero length file
$ echo $?
2
$ ls -l GMC3
total 154
-rw-r--r-- 1 naomi gmc3 71311 Aug 19 09:27 data80-90.z
---x--x--x 1 naomi gmc3 5366 Mar 15 12:50 print
-rw-r--r-- 1 naomi gmc3 899 Jan 10 17:02 user.old.z
-rw-r--r-- 1 naomi gmc3 0 Mar 14 13:16 user.new
SEE ALSO
compress(1), pcat(1), uncompress(1), unpack(1), zcat(1).
Page 6 Reliant UNIX 5.44 Printed 11/98