Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cat(1)

compress(1)

/uncompress(1)

/zcat(1)

pack(1)  —  Commands

OSF

NAME

pack, pcat, unpack − Compresses and expands files

SYNOPSIS

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

unpack file[.z] ... 

pcat file[.z] ... 

The pack command stores the specified file in a compressed form.  The input file is replaced by a packed file with a name derived from the original filename (file.z), with the same access modes, access and modification dates, and owner as the original file. 

FLAGS

-Displays statistics about the input files. The statistics are calculated from a Huffman minimum redundancy code tree built on a byte-by-byte basis.  Repeating the - (dash) on the command line toggles this function. 

-fForces compaction of input files. 

DESCRIPTION

Directories cannot be compressed. 

If pack cannot create a smaller file, it stops processing and reports that it is unable to save space, unless you specify -f.  (The -f flag forces packing to occur even if the files cannot benefit from packing.)  A failure to save space generally happens with small files or files with uniform character distribution. 

The amount of space saved 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, you will generally not be able to save space with files smaller than three blocks.  Typically, text files are reduced 25 to 40 percent. 

The exit value of the pack command is the number of files that it could not pack.  Packing is not done under any one of the following conditions:

       •The file is already packed. 

       •The file has links. 

       •The file is a directory. 

       •The file cannot be opened. 

       •No storage blocks are saved by packing. 

       •A file called file.z already exists. 

       •The .z file cannot be created. 

       •An I/O error occurs during processing. 

pcat

The pcat command reads the specified files, unpacks them, and writes them to standard output. 

The exit value of pcat is the number of files it was unable to unpack.  A file cannot be unpacked if any one of the following occurs:

       •The filename (exclusive of the .z) has more than 12 bytes. 

       •The file cannot be opened. 

       •The file is not a packed file. 

unpack

The unpack command expands files created by pack.  For each file specified, unpack searches for a file called file.z.  If this file is a packed file, unpack replaces it by its expanded version.  The unpack command names the new filename by removing the .z suffix from file.  The new file has the same access modes, access and modification dates, and owner as the original packed file. 

The exit value is the number of files the unpack command was unable to unpack.  A file cannot be unpacked if any one of the following occurs:

       •The file cannot be opened. 

       •The file is not a packed file. 

       •A file with the unpacked filename already exists. 

       •The unpacked file cannot be created. 

EXAMPLES

     1.To compress files, enter:

pack chap1 chap2

This compresses the files chap1 and chap2, replacing them with files named chap1.z and chap2.z.  The pack command displays the percent decrease in size for each file. 

     2.To display statistics about the amount of compression done, enter:

pack  -  chap1  -  chap2

This compresses the files chap1 and chap2 and displays statistics about chap1, but not about chap2.  The first - (dash) turns on the statistic display, and the second turns it off. 

     3.To display compressed files, enter:

pcat  chap1.z  chap2 |  more

This displays the compressed files chap1.z and chap2.z on the screen in expanded form, a page at a time (more).  Note that pcat added the .z to the end of chap2, even though it was not entered. 

     4.To use a compressed file without expanding the copy stored on disk, enter:

pcat chap1.z  |  grep  ’Greece’

This pipes the contents of chap1.z in its expanded form to the grep command. 

     5.To unpack packed files, enter:

unpack  chap1.z  chap2

This expands the packed files chap1.z and chap2.z, replacing them with files named chap1 and chap2.  Note that you can give unpack filenames either with or without the .z suffix. 

NOTES

     1.Both pcat and unpack operate only on files ending in .z.  As a result, when you specify a filename that does not end in .z, pcat and unpack add the suffix and search the directory for a filename with that suffix. 

     2.The unpack command writes a warning to standard output if the file it is unpacking has links.  The new unpacked file has a different inode than the packed file from which it was created.  However, any other files linked to the packed file’s original inode still exist and are still packed. 

     3.If pack is used on files residing on a System V file system, the filenames must contain no more than 12 bytes to allow space for the added .z extension. 

     4.If you try to use pack on a very small file, you might receive the following message:

pack filename: No saving -- file unchanged

EXIT VALUES

The return value of the pack command is the number of files that it could not pack.  The exit value of both the pcat and unpack commands is the number of files it was unable to unpack. 

RELATED INFORMATION

Commands:  cat(1), compress(1)/uncompress(1)/zcat(1). 

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