'\" te .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1996, 2015, Oracle and/or its affiliates.All rights reserved. .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" 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 Sun OS 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. .TH pack 1 "2015 年 4 月 6 日" "SunOS 5.11" "用户命令" .SH 名称 pack, pcat, unpack \- 压缩和解压缩文件 .SH 用法概要 .LP .nf \fBpack\fR [\fB-f/\fR] [\fB-\fR] \fIfile\fR... .fi .LP .nf \fBpcat\fR \fIfile\fR... .fi .LP .nf \fBunpack\fR [\fB-/\fR] \fIfile\fR... .fi .SH 描述 .SS "pack" .sp .LP \fBpack\fR 命令会尝试以压缩格式存储指定文件。如果可能(并且有用),每个输入文件 \fBfile\fR 都会替换为打包文件 \fBfile\fR\fB\&.z\fR,而且后者与 \fBfile\fR 拥有相同的访问模式、访问和修改日期以及所有者。如果 \fBpack\fR 成功,则会删除 \fBfile\fR。 .sp .LP 压缩程度取决于输入文件的大小和字频分布。因为每个 \fB\&.z\fR 文件的第一部分由解码树构成,所以通常不值得打包小于三个块的文件,除非字频分布非常倾斜,而这种情况会出现在打印绘图或图片上。 .sp .LP 通常,文本文件的大小会降至原始大小的 60-75%。装入模块由于使用了更大的字符集并且具有更加一致的字符分布,因此压缩程度较小,其打包后的大小约为原始大小的 90%。 .sp .LP \fBpack\fR 实用程序会返回一个值,即压缩失败的文件的数量。如果文件数量超过 \fB255\fR,则返回 \fB255\fR。 .sp .LP 如果出现以下情况,则不进行打包: .RS +4 .TP .ie t \(bu .el o 文件看起来已经过打包 .RE .RS +4 .TP .ie t \(bu .el o 文加名太长,无法添加 \fB\&.z\fR 后缀 .RE .RS +4 .TP .ie t \(bu .el o 文件有链接 .RE .RS +4 .TP .ie t \(bu .el o 文件是一个目录 .RE .RS +4 .TP .ie t \(bu .el o 文件无法打开 .RE .RS +4 .TP .ie t \(bu .el o 文件为空 .RE .RS +4 .TP .ie t \(bu .el o 打包时未保存任何磁盘存储块 .RE .RS +4 .TP .ie t \(bu .el o 名为 \fBfile\fR\fB\&.z\fR 的文件已存在 .RE .RS +4 .TP .ie t \(bu .el o 无法创建 \fB\&.z\fR 文件 .RE .RS +4 .TP .ie t \(bu .el o 处理过程中发生 I/O 错误。 .RE .sp .LP 文件名的最后部分必须足够短,以便为附加的 \fB\&.z\fR 扩展名留出空间。目录无法压缩。 .SS "pcat" .sp .LP \fBpcat\fR 命令对打包文件执行的操作即为 \fBcat\fR(1) 对原始文件执行的操作,但 \fBpcat\fR 不能用作过滤器。对指定文件进行解压缩并写入标准输出。 .sp .LP \fBpcat\fR 会返回无法解压缩的文件的数量。出现以下情况时会发生故障: .RS +4 .TP .ie t \(bu .el o 文件无法打开; .RE .RS +4 .TP .ie t \(bu .el o 文件看起来不是 \fBpack\fR 的输出。 .RE .SS "unpack" .sp .LP \fBunpack\fR 命令用于解压缩 \fBpack\fR 所创建的文件。对于在此命令中指定的每个 \fBfile\fR,系统会对称作 \fBfile\fR\fB\&.z\fR(或者只是 \fBfile\fR,如果 \fBfile\fR 以 \fB\&.z\fR 结尾)的文件执行搜索。如果此文件看上去是打包文件,则替换为它的解压缩版本。新文件会删除其名称中的 \fB\&.z\fR 后缀,并且与打包文件有着相同的访问模式、访问和修改日期以及所有者。 .sp .LP \fBunpack\fR 会返回一个值,即无法解压缩的文件的数量。除了与 \fBpcat\fR 中相同的故障原因外,它还会在以下情况下发生故障: .RS +4 .TP .ie t \(bu .el o 具有解压缩名称的文件已存在; .RE .RS +4 .TP .ie t \(bu .el o 无法创建解压缩文件。 .RE .SH 选项 .sp .LP \fBpack\fR 支持以下选项: .sp .ne 2 .mk .na \fB\fB-f\fR\fR .ad .RS 6n .rt 强制对 \fBfile\fR 进行打包。这有助于打包整个目录,即使有些文件不会从中受益。使用 \fBunpack\fR 或 \fBpcat\fR 可以将打包文件恢复到原始格式。 .RE .sp .LP \fBpack\fR 和 \fBunpack\fR 支持以下选项: .sp .ne 2 .mk .na \fB\fB-/\fR\fR .ad .RS 6n .rt 打包或解压缩时,将任何与源文件相关的 ACL 和扩展系统属性都复制到目标文件。如果无法复制 ACL 或扩展系统属性,则保留原始文件,向 \fBstderr\fR 写入一条诊断消息,且最终退出状态为\fB非零值\fR。 .RE .SH 操作数 .sp .LP 支持下列操作数: .sp .ne 2 .mk .na \fB\fBfile\fR\fR .ad .RS 8n .rt 要打包、解压缩或执行 pcat 命令的文件的路径名;\fBfile\fR 可以包含或忽略 \fB\&.z\fR 后缀。 .RE .sp .ne 2 .mk .na \fB\fB-\fR\fR .ad .RS 8n .rt \fBpack\fR 会逐字节使用霍夫曼(最小冗余)编码。如果使用 \fB-\fR 参数,则会设置一个内部标志,使每个字节的使用次数、相对频率和字节代码输出到标准输出中。使用更多 \fB-\fR 替换 \fBfile\fR 会使得系统设置和重置内部标志。 .RE .SH 用法 .sp .LP 有关 \fBpack\fR、\fBpcat\fR 和 \fBunpack\fR 遇到大于或等于 2 GB (2^31 字节)文件时行为的说明,请参见 \fBlargefile\fR(5)。 .SH 示例 .LP \fB示例 1 \fR查看打包文件 .sp .LP 要查看名为 \fBfile.z\fR 的打包文件,请使用: .sp .LP \fBexample%\fR \fBpcat\fR \fBfile.z\fR .sp .LP 或仅使用: .sp .LP \fBexample%\fR \fBpcat\fR \fBfile\fR .LP \fB示例 2 \fR制作解压缩副本: .sp .LP 要制作名为 \fBfile.z\fR 的打包文件的解压缩副本,例如 \fBnnn\fR(同时不损坏 \fBfile.z\fR),请使用命令: .sp .LP \fBexample%\fR \fBpcat\fR \fBfile\fR \fB>nnn\fR .SH 环境变量 .sp .LP 有关影响 \fBpack\fR、\fBpcat\fR 和 \fB unpack\fR 执行的 \fBLC_CTYPE\fR、\fBLC_MESSAGES\fR 和 \fBNLSPATH\fR 环境变量的说明,请参见 \fBenviron\fR(5)。 .SH 退出状态 .sp .LP 将返回以下退出值: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt 成功完成。 .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt 出现错误。返回命令未能打包/解压缩的文件的数量。如果失败数量超过 \fB255\fR,则返回 \fB255\fR。 .RE .SH 属性 .sp .LP 有关下列属性的说明,请参见 \fBattributes\fR(5): .sp .sp .TS tab() box; lw(2.75i) |lw(2.75i) lw(2.75i) |lw(2.75i) . 属性类型\fB\fR属性值\fB\fR _ 可用性system/core-os _ CSIEnabled(已启用) .TE .SH 另请参见 .sp .LP \fBcat\fR(1)、\fBcompress\fR(1)、\fBzcat\fR(1)、\fBfgetattr\fR(3C)、\fBfsetattr\fR(3C)\fBattributes\fR(5)、\fBenviron\fR(5)、\fBlargefile\fR(5) .SH 附注 .sp .LP 该命令已废弃,可能会从将来的 Oracle Solaris 发行版中删除。