xref: /illumos-gate/usr/src/man/man1/pack.1 (revision 6e6545bfaed3bab9ce836ee82d1abd8f2edba89a)

Sun Microsystems, Inc. gratefully acknowledges The Open Group for
permission to reproduce portions of its copyrighted documentation.
Original documentation from The Open Group can be obtained online at
http://www.opengroup.org/bookstore/.

The Institute of Electrical and Electronics Engineers and The Open
Group, have given us permission to reprint portions of their
documentation.

In the following statement, the phrase ``this text'' refers to portions
of the system documentation.

Portions of this text are reprinted and reproduced in electronic form
in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
Standard for Information Technology -- Portable Operating System
Interface (POSIX), The Open Group Base Specifications Issue 6,
Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
Engineers, Inc and The Open Group. In the event of any discrepancy
between these versions and the original IEEE and The Open Group
Standard, the original IEEE and The Open Group Standard is the referee
document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html.

This notice shall appear on any product containing this material.

The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.

You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.

When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]


Copyright 1989 AT&T
Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved

PACK 1 "Mar 13, 2008"
NAME
pack, pcat, unpack - compress and expand files
SYNOPSIS

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

pcat file...

unpack [-/] file...
DESCRIPTION
"pack"

The pack command attempts to store the specified files in a compressed form. Wherever possible (and useful), each input file file is replaced by a packed file file.z with the same access modes, access and modified dates, and owner as those of file. If pack is successful, file is removed.

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 very skewed, which can 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 being about 90% of the original size.

The pack utility returns a value that is the number of files that it failed to compress. If that number exceeds 255, 255 is returned.

No packing occurs if:

the file appears to be already packed

the file name is too long to add the .z suffix

the file has links

the file is a directory

the file cannot be opened

the file is empty

no disk storage blocks are 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 file name must be short enough to allow space for the appended .zextension. Directories cannot be compressed.

"pcat"

The pcat command does for packed files what cat(1) does for ordinary files, except that pcat cannot be used as a filter. The specified files are unpacked and written to the standard output.

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

the file cannot be opened;

the file does not appear to be the output of pack.

"unpack"

The unpack command expands files created by pack. For each file specified in the command, a search is made for a file called file.z (or just file, if file 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.

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

a file with the unpacked name already exists;

the unpacked file cannot be created.

OPTIONS

The following options are supported by pack: -f

Forces packing of file. This is useful for causing an entire directory to be packed even if some of the files do not benefit. Packed files can be restored to their original form using unpack or pcat.

The following options are supported by pack and unpack: -/

When packing or unpacking, copies any ACL and extended system attributes associated with the source file to the target file. If an ACL or extended system attributes cannot be copied, the original file is retained, a diagnostic message is written to stderr, and the final exit status is non-zero.

OPERANDS

The following operands are supported: file

A path name of a file to be packed, unpacked, or pcated; file can include or omit the .z suffix.

-

pack uses Huffman (minimum redundancy) codes on a byte-by-byte basis. If the - argument is used, 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 - in place of file causes the internal flag to be set and reset.

USAGE

See largefile(5) for the description of the behavior of pack, pcat, and unpack when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).

EXAMPLES

Example 1 Viewing a Packed File

To view a packed file named file.z use:

example% pcat file.z

or just:

example% pcat file

Example 2 Making and Unpacked Copy:

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

example% pcat file >nnn

ENVIRONMENT VARIABLES

See environ(5) for descriptions of the following environment variables that affect the execution of pack, pcat, and unpack: LC_CTYPE, LC_MESSAGES, and NLSPATH.

EXIT STATUS

The following exit values are returned: 0

Successful completion.

>0

An error occurred. The number of files the command failed to pack/unpack is returned. If the number of failures exceeds 255, then 255 is returned.

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
CSI Enabled
SEE ALSO

cat(1), compress(1), zcat(1), fgetattr(3C), fsetattr(3C), attributes(5), environ(5), largefile(5)