命令行大全

pack

瑞兹 发表于 2020-10-30 09:49浏览次数:

在类似Unix的操作系统上,pack命令是使用Huffman编码的Unix文件压缩程序。

查看英文版

目录:

1 pack 运行系统环境

2 pack 描述

3 pack 语法

4 pack 例子

pack 运行系统环境

Linux

pack 描述

pack使用Huffman最小冗余码按字节压缩文件。每个文件都压缩到位;生成的文件在文件名后附加.z 扩展名,但保留相同的所有者和权限。最后访问和最后修改的时间也被保留。

打包的文件可以由文件标识,并可以通过解压缩(将文件解压缩到适当位置)或pcat(将其解压缩到标准输出)解压缩。

通常,pack报告在每个文件中达到的压缩程度,将报告打印到标准输出。如果使用-f选项,则该数字可以为负,特别是对于内容很少有冗余的小文件。

在以下情况下,pack不打包文件:

  • 该文件似乎已经打包。 
  • 文件名太长(如果文件扩展名已经是.z,则会发生错误)。
  • 该文件具有链接或为目录。 
  • 打包的文件将大于现有文件(包括空文件)。 
  • 目标文件已存在,或处理中存在错误。

pack compresses files using a Huffman minimal redundancy code on a byte basis. Each file is compressed in place; the resulting file has a .z extension appended to the file name, but keeps the same owner and permissions. The times of last access and last modification are also preserved.

Packed files can be identified by file and uncompressed by unpack (which unpacks the file in place) or pcat (which unpacks to the standard output).

Normally pack reports the degree of compression achieved in each file, printing the report to standard output. This number can be negative, especially for small files with little redundancy in their contents, if the -f option is used.

pack does not pack files if:

  • The file appears to have already been packed. 
  • The file name is too long (an error will occur if it already has a .z extension). 
  • The file has links or is a directory. 
  • The packed file would be larger than the existing file (this includes empty files). 
  • The destination file already exists, or there is an error in processing.

查看英文版

查看中文版

pack 语法

pack [[-][-B] [-f] [-o file] file] ...

选件

- 显示有关大小,开销和“熵”(信息率)的更多详细信息。如果在命令行上多次使用此选项,它将充当切换按钮。
-F 在正常情况下不会发生压缩。如果没有此选项,如果未通过压缩减小文件的大小,该文件已被压缩或者该文件具有多个链接,则pack不会压缩文件。
-o file 指定另一个输出文件,以便将压缩的输出写入文件,而不是覆盖原始输入文件。可以指定几个输入和输出文件。例如,
pack -o out1 in1 -o out2 in2
将文件in1打包到out1并将文件in2打包到out2。输入文件未更改。

退出码

0 操作成功。
0 错误代码大于零表示发生了错误。pack无法压缩的文件数作为退出代码返回。
pack [[-][-B] [-f] [-o file] file] ...

Options

- Displays more detail on size, overhead and "entropy" (information rate). If this option is used several times on the command line it acts as a toggle.
-f Forces compression when it normally would not occur. Without this option, pack does not compress a file if its size is not reduced by compression, the file is already compressed, or the file has more than one link.
-o file Specifies a different output file so that compressed output is written to file rather than overwriting the original input file. Several input and output files may be specified. For example,
pack -o out1 in1 -o out2 in2
packs file in1 into out1 and file in2 into out2. The input files are not changed.

Exit Codes

0 Operation successful.
>0 An error code greater than zero indicates that an error occurred. The number of files that pack was unable to compress are returned as the exit code.

查看英文版

查看中文版

pack 例子

pack myfile.txt

打包文件myfile.txt并将该文件重命名为myfile.txt.z。成功完成后,pack将报告类似于以下内容的压缩统计信息:

pack: myfile.txt: -1.8% Compression
pack myfile.txt

Packs the file myfile.txt and renames that file to myfile.txt.z. On successful completion, pack will report compression statistics similar to the following:

pack: myfile.txt: -1.8% Compression

查看英文版

查看中文版