命令行大全

compress

rose1 发表于 2020-08-24 10:28浏览次数:

在类似Unix的操作系统上,compress命令压缩文件,使其变得更小。 压缩文件的名称后缀为.Z。 本文档介绍GNU / Linux版本的compress。

查看英文版

目录:

1 compress 运行系统环境

2 compress 说明

3 compress 语法

4 compress 例子

compress 运行系统环境

Linux

compress 说明

compress实用程序使用自适应Lempel-Ziv 编码减小文件的大小。每个文件都重命名为同一个名称加上扩展名。Z. 具有的文件参数。Z扩展将被忽略,除非它将导致错误退出后,其他参数处理。如果压缩不会减小文件的大小,则忽略该文件。

由于许多修改时间、访问时间、文件标志、文件模式、用户 ID 和组 ID的权限允许,这些修改时间都保留在新文件中。

如果未指定文件或文件参数是单个破折号('-'),则标准输入将压缩到标准输出。如果输入和输出文件不是常规文件,则不执行减小大小和文件覆盖的检查,不删除输入文件,并且输入文件的属性不会保留在输出文件中。

压缩实用程序使用修改后的伦佩尔-齐夫算法。文件中的常见子字符串首先由 9 位代码 257 及更上版本替换。当达到代码 512 时,算法切换到 10 位代码,并继续使用更多位,直到达到 -b 选项指定的限制或其默认值。

达到限制后,压缩会定期检查压缩比。如果它正在增加,压缩将继续使用现有的代码字典。但是,如果压缩比降低,压缩丢弃子字符串表并从头开始重新生成,这允许算法适应文件的下一个"块"。

获得的压缩量取决于输入的大小、每个代码的位数以及公共子字符串的分布。通常,源代码或英语等文本减少了 50-60%!压缩通常比赫夫曼编码(在历史命令包中使用的)或自适应赫夫曼编码(历史命令"紧凑"中使用的)实现的压缩要好得多,而且计算时间更少。

The compress utility reduces the size of files using adaptive Lempel-Zivcoding. Each file is renamed to the same name plus the extension .Z. A file argument with a .Z extension will be ignored except it will cause an error exit after other arguments are processed. If compression would not reduce the size of a file, the file is ignored.

As many of the modification time, access time, file flags, file mode, user ID, and group ID as allowed by permissions are retained in the new file.

If no files are specified or a file argument is a single dash ('-'), the standard input is compressed to the standard output. If either the input and output files are not regular files, the checks for reduction in size and file overwriting are not performed, the input file is not removed, and the attributes of the input file are not retained in the output file.

The compress utility uses a modified Lempel-Ziv algorithm. Common substrings in the file are first replaced by 9-bit codes 257 and up. When code 512 is reached, the algorithm switches to 10-bit codes and continues to use more bits until the limit specified by the -b option or its default is reached.

After the limit is reached, compress periodically checks the compression ratio. If it is increasing, compress continues to use the existing code dictionary. However, if the compression ratio decreases, compress discards the table of substrings and rebuilds it from scratch, which allows the algorithm to adapt to the next "block" of the file.

The amount of compression obtained depends on the size of the input, the number of bits per code, and the distribution of common substrings. Typically, text such as source code or English is reduced by 50-60%! Compression is generally much better than that achieved by Huffmancoding (as used in the historical command pack), or adaptive Huffman coding (as used in the historical command "compact"), and takes less time to compute.

查看英文版

查看中文版

compress 语法

compress [-fv] [-b bits] [file ...]
compress -c [-b bits] [file]

选件

-b bits

代码大小被限制为比特,它必须是在范围9 .. 16。默认值为16。

-c

压缩或未压缩的输出将写入标准输出。没有文件被修改。该-v选项被忽略。即使结果将大于原始值,也会尝试进行压缩。

-f

文件将被覆盖,而不会提示您进行确认。此外,即使文件实际上没有减小,文件也将被压缩。

-v

打印每个文件的减少百分比。如果还使用-c选项,则忽略此选项。

compress [-fv] [-b bits] [file ...]
compress -c [-b bits] [file]

Options

-b bits

The code size is limited to bits, which must be in the range 9..16. The default is 16.

-c

Compressed or uncompressed output is written to the standard output. No files are modified. The -v option is ignored. Compression is attempted even if the results will be larger than the original.

-f

Files are overwritten without prompting for confirmation. Also, files are compressed even if they are not actually reduced in size.

-v

Print the percentage reduction of each file. This option is ignored if the -c option is also used.

查看英文版

查看中文版

compress 例子

compress -v bigfile.exe

压缩bigfile.exe并将该文件重命名为bigfile.exe.Z。

compress -v bigfile.exe

Compress bigfile.exe and rename that file to bigfile.exe.Z.

查看英文版

查看中文版