Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cat(1)

compress(1)

pack(1)

Name

pack, pcat, unpack − compress and expand files

Syntax

pack [ − ] [ −f ] name... 

pcat name... 

unpack name... 

Description

The pack command stores the specified files in a compressed form. Wherever possible (and useful), each input file name is replaced by a packed file name.z with the same access modes, access and modified dates, and owner as those of name.  The −f option forces packing of name.  Using this option you can cause an entire directory to be packed even if some of the files cannot benefit from it.  If pack is successful, name is removed.  Packed files can be restored to their original form using unpack or pcat.

The pack command uses Huffman (minimum redundancy) codes on a byte-by-byte basis. If a hyphen (−) is used as an argument, an internal flag is set that causes the number of times each byte is used, its relative frequency, and the code for the byte to be printed on the standard output. Additional occurrences of a hyphen (−) in place of name causes the internal flag to be set and reset. 

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

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

The pack command returns a value that is the number of files that it failed to compress.

No packing occurs if one of the following is true:

•The file appears packed. 

•The file name exceeds 12 characters. 

•The file has links. 

•The file is a directory. 

•The file cannot be opened. 

•No disk storage blocks can be saved by packing. 

•A file called name.z already exists.

•The .z file cannot be created. 

•An I/O error occurred during processing. 

The last segment of the file name must not exceed 12 characters to allow space for the appended .z extension.  Directories cannot be compressed. 

The pcat command does for packed files what cat() does for ordinary files, except that pcat can not be used as a filter. The specified files are unpacked and written to the standard output. Thus, to view a packed file named name.z use:

pcat name.z

or just:

pcat name

To make an unpacked copy, say nnn, of a packed file named name.z (without destroying name.z) use the command:

pcat name >nnn

The pcat command returns the number of files it was unable to unpack. Failure may occur if:

the file name (exclusive of the .z) has more than 12 characters;
the file cannot be opened;
the file does not appear to be the output of pack. 

The unpack command expands files created by pack. For each file name specified in the command, a search is made for a file called name.z (or just name, if name ends in .z).  If this file appears to be a packed file, it is replaced by its expanded version.  The new file has the .z suffix stripped from its name, and has the same access modes, access and modification dates, and owner as those of the packed file. 

The unpack command returns a value that is the number of files it was unable to unpack. Failure occurs for the same reasons that it occurs in pcat, as well as for the following:

a file with the unpacked name already exists;
if the unpacked file cannot be created.

This command is present only for compatibility.  In general, the compress() command runs faster and gives better compression.

See Also

cat(1), compress(1)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026