1 .\"
   2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
   3 .\" permission to reproduce portions of its copyrighted documentation.
   4 .\" Original documentation from The Open Group can be obtained online at
   5 .\" http://www.opengroup.org/bookstore/.
   6 .\"
   7 .\" The Institute of Electrical and Electronics Engineers and The Open
   8 .\" Group, have given us permission to reprint portions of their
   9 .\" documentation.
  10 .\"
  11 .\" In the following statement, the phrase ``this text'' refers to portions
  12 .\" of the system documentation.
  13 .\"
  14 .\" Portions of this text are reprinted and reproduced in electronic form
  15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
  16 .\" Standard for Information Technology -- Portable Operating System
  17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
  18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
  19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
  20 .\" between these versions and the original IEEE and The Open Group
  21 .\" Standard, the original IEEE and The Open Group Standard is the referee
  22 .\" document.  The original Standard can be obtained online at
  23 .\" http://www.opengroup.org/unix/online.html.
  24 .\"
  25 .\" This notice shall appear on any product containing this material.
  26 .\"
  27 .\" The contents of this file are subject to the terms of the
  28 .\" Common Development and Distribution License (the "License").
  29 .\" You may not use this file except in compliance with the License.
  30 .\"
  31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  32 .\" or http://www.opensolaris.org/os/licensing.
  33 .\" See the License for the specific language governing permissions
  34 .\" and limitations under the License.
  35 .\"
  36 .\" When distributing Covered Code, include this CDDL HEADER in each
  37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  38 .\" If applicable, add the following below this CDDL HEADER, with the
  39 .\" fields enclosed by brackets "[]" replaced with your own identifying
  40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
  41 .\"
  42 .\"
  43 .\" Copyright 1989 AT&T
  44 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
  45 .\" Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved
  46 .\"
  47 .TH PACK 1 "Feb 5, 2020"
  48 .SH NAME
  49 pack, pcat, unpack \- compress and expand files
  50 .SH SYNOPSIS
  51 .nf
  52 \fBpack\fR [\fB-f/\fR] [\fB-\fR] \fIfile\fR...
  53 .fi
  54 
  55 .LP
  56 .nf
  57 \fBpcat\fR \fIfile\fR...
  58 .fi
  59 
  60 .LP
  61 .nf
  62 \fBunpack\fR [\fB-/\fR] \fIfile\fR...
  63 .fi
  64 
  65 .SH DESCRIPTION
  66 .SS "pack"
  67 The \fBpack\fR command attempts to store the specified files in a compressed
  68 form. Wherever possible (and useful), each input file \fBfile\fR is replaced by
  69 a packed file \fBfile\fR\fB\&.z\fR with the same access modes, access and
  70 modified dates, and owner as those of \fBfile\fR. If \fBpack\fR is successful,
  71 \fBfile\fR is removed.
  72 .sp
  73 .LP
  74 The amount of compression obtained depends on the size of the input file and
  75 the character frequency distribution. Because a decoding tree forms the first
  76 part of each \fB\&.z\fR file, it is usually not worthwhile to pack files
  77 smaller than three blocks, unless the character frequency distribution is very
  78 skewed, which can occur with printer plots or pictures.
  79 .sp
  80 .LP
  81 Typically, text files are reduced to 60-75% of their original size. Load
  82 modules, which use a larger character set and have a more uniform distribution
  83 of characters, show little compression, the packed versions being about 90% of
  84 the original size.
  85 .sp
  86 .LP
  87 The \fBpack\fR utility returns a value that is the number of files that it
  88 failed to compress. If that number exceeds \fB255\fR, \fB255\fR is returned.
  89 .sp
  90 .LP
  91 No packing occurs if:
  92 .RS +4
  93 .TP
  94 .ie t \(bu
  95 .el o
  96 the file appears to be already packed
  97 .RE
  98 .RS +4
  99 .TP
 100 .ie t \(bu
 101 .el o
 102 the file name is too long to add the \fB\&.z\fR suffix
 103 .RE
 104 .RS +4
 105 .TP
 106 .ie t \(bu
 107 .el o
 108 the file has links
 109 .RE
 110 .RS +4
 111 .TP
 112 .ie t \(bu
 113 .el o
 114 the file is a directory
 115 .RE
 116 .RS +4
 117 .TP
 118 .ie t \(bu
 119 .el o
 120 the file cannot be opened
 121 .RE
 122 .RS +4
 123 .TP
 124 .ie t \(bu
 125 .el o
 126 the file is empty
 127 .RE
 128 .RS +4
 129 .TP
 130 .ie t \(bu
 131 .el o
 132 no disk storage blocks are saved by packing
 133 .RE
 134 .RS +4
 135 .TP
 136 .ie t \(bu
 137 .el o
 138 a file called \fBfile\fR\fB\&.z\fR already exists
 139 .RE
 140 .RS +4
 141 .TP
 142 .ie t \(bu
 143 .el o
 144 the \fB\&.z\fR file cannot be created
 145 .RE
 146 .RS +4
 147 .TP
 148 .ie t \(bu
 149 .el o
 150 an I/O error occurred during processing.
 151 .RE
 152 .sp
 153 .LP
 154 The last segment of the file name must be short enough to allow space for the
 155 appended \fB\&.z\fR extension. Directories cannot be compressed.
 156 .SS "pcat"
 157 The \fBpcat\fR command does for packed files what \fBcat\fR(1) does for
 158 ordinary files, except that \fBpcat\fR cannot be used as a filter. The
 159 specified files are unpacked and written to the standard output.
 160 .sp
 161 .LP
 162 \fBpcat\fR returns the number of files it was unable to unpack. Failure can
 163 occur if:
 164 .RS +4
 165 .TP
 166 .ie t \(bu
 167 .el o
 168 the file cannot be opened;
 169 .RE
 170 .RS +4
 171 .TP
 172 .ie t \(bu
 173 .el o
 174 the file does not appear to be the output of \fBpack\fR.
 175 .RE
 176 .SS "unpack"
 177 The \fBunpack\fR command expands files created by \fBpack\fR. For each
 178 \fBfile\fR specified in the command, a search is made for a file called
 179 \fBfile\fR\fB\&.z\fR (or just \fBfile\fR, if \fBfile\fR ends in \fB\&.z\fR). If
 180 this file appears to be a packed file, it is replaced by its expanded version.
 181 The new file has the \fB\&.z\fR suffix stripped from its name, and has the same
 182 access modes, access and modification dates, and owner as those of the packed
 183 file.
 184 .sp
 185 .LP
 186 \fBunpack\fR returns a value that is the number of files it was unable to
 187 unpack. Failure can occur for the same reasons that it can in \fBpcat\fR, as
 188 well as for the following:
 189 .RS +4
 190 .TP
 191 .ie t \(bu
 192 .el o
 193 a file with the unpacked name already exists;
 194 .RE
 195 .RS +4
 196 .TP
 197 .ie t \(bu
 198 .el o
 199 the unpacked file cannot be created.
 200 .RE
 201 .SH OPTIONS
 202 The following options are supported by \fBpack\fR:
 203 .sp
 204 .ne 2
 205 .na
 206 \fB\fB-f\fR\fR
 207 .ad
 208 .RS 6n
 209 Forces packing of \fBfile\fR. This is useful for causing an entire directory to
 210 be packed even if some of the files do not benefit. Packed files can be
 211 restored to their original form using \fBunpack\fR or \fBpcat\fR.
 212 .RE
 213 
 214 .sp
 215 .LP
 216 The following options are supported by \fBpack\fR and \fBunpack\fR:
 217 .sp
 218 .ne 2
 219 .na
 220 \fB\fB-/\fR\fR
 221 .ad
 222 .RS 6n
 223 When packing or unpacking, copies any ACL and extended system attributes
 224 associated with the source file to the target file. If an ACL or extended
 225 system attributes cannot be copied, the original file is retained, a diagnostic
 226 message is written to \fBstderr\fR, and the final exit status is
 227 \fBnon-zero\fR.
 228 .RE
 229 
 230 .SH OPERANDS
 231 The following operands are supported:
 232 .sp
 233 .ne 2
 234 .na
 235 \fB\fBfile\fR\fR
 236 .ad
 237 .RS 8n
 238 A path name of a file to be packed, unpacked, or pcated; \fBfile\fR can include
 239 or omit the \fB\&.z\fR suffix.
 240 .RE
 241 
 242 .sp
 243 .ne 2
 244 .na
 245 \fB\fB\(mi\fR\fR
 246 .ad
 247 .RS 8n
 248 \fBpack\fR uses Huffman (minimum redundancy) codes on a byte-by-byte basis. If
 249 the \fB\(mi\fR argument is used, an internal flag is set that causes the number
 250 of times each byte is used, its relative frequency, and the code for the byte
 251 to be printed on the standard output. Additional occurrences of \fB\(mi\fR in
 252 place of \fBfile\fR causes the internal flag to be set and reset.
 253 .RE
 254 
 255 .SH USAGE
 256 See \fBlargefile\fR(5) for the description of the behavior of \fBpack\fR,
 257 \fBpcat\fR, and \fBunpack\fR when encountering files greater than or equal to 2
 258 Gbyte (2^31 bytes).
 259 .SH EXAMPLES
 260 \fBExample 1 \fRViewing a Packed File
 261 .sp
 262 .LP
 263 To view a packed file named \fBfile.z\fR use:
 264 
 265 .sp
 266 .LP
 267 \fBexample%\fR \fBpcat\fR \fBfile.z\fR
 268 
 269 .sp
 270 .LP
 271 or just:
 272 
 273 .sp
 274 .LP
 275 \fBexample%\fR \fBpcat\fR \fBfile\fR
 276 
 277 .LP
 278 \fBExample 2 \fRMaking an Unpacked Copy:
 279 .sp
 280 .LP
 281 To make an unpacked copy, say \fBnnn\fR, of a packed file named \fBfile.z\fR
 282 (without destroying \fBfile.z\fR) use the command:
 283 
 284 .sp
 285 .LP
 286 \fBexample%\fR \fBpcat\fR \fBfile\fR \fB>nnn\fR
 287 
 288 .SH ENVIRONMENT VARIABLES
 289 See \fBenviron\fR(5) for descriptions of the following environment variables
 290 that affect the execution of \fBpack\fR, \fBpcat\fR, and \fBunpack\fR:
 291 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
 292 .SH EXIT STATUS
 293 The following exit values are returned:
 294 .sp
 295 .ne 2
 296 .na
 297 \fB\fB0\fR\fR
 298 .ad
 299 .RS 6n
 300 Successful completion.
 301 .RE
 302 
 303 .sp
 304 .ne 2
 305 .na
 306 \fB\fB>0\fR\fR
 307 .ad
 308 .RS 6n
 309 An error occurred. The number of files the command failed to pack/unpack is
 310 returned. If the number of failures exceeds \fB255\fR, then \fB255\fR is
 311 returned.
 312 .RE
 313 
 314 .SH ATTRIBUTES
 315 See \fBattributes\fR(5) for descriptions of the following attributes:
 316 .sp
 317 
 318 .sp
 319 .TS
 320 box;
 321 c | c
 322 l | l .
 323 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 324 _
 325 CSI     Enabled
 326 .TE
 327 
 328 .SH SEE ALSO
 329 \fBcat\fR(1), \fBcompress\fR(1), \fBzcat\fR(1), \fBfgetattr\fR(3C),
 330 \fBfsetattr\fR(3C), \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5)