适用于Linux的Gzip命令教程

Gzip is actually a file format which is a compressed file. There is also a tool named gzip which is used to compress and decompress files. Gzip is developed in 1992. It use DEFLATE algorithm with LZ77 and Huffman coding.

Gzip实际上是一种压缩文件格式。 还有一个名为gzip的工具,用于压缩和解压缩文件。 Gzip开发于1992年。它使用带有LZ77和霍夫曼编码的DEFLATE算法。

gzip命令帮助 (gzip Command Help)

gzip command provides different options. These options and help information can be listed with the -h option like below.

gzip命令提供了不同的选项。 可以使用-h选项列出这些选项和帮助信息,如下所示。

$ gzip  -h
Help
Help
帮帮我

使用gzip命令压缩文件(Compress File with gzip Command)

Gzip can only compress files. It cannot compress multiple files folder or folders. Gzip command is generally used with tar command. We will only provide the file to be compressed. In this example, we will compress thefile.txt . The output file name will be the same with just adding .gz extension.

Gzip只能压缩文件。 它不能压缩一个或多个文件夹。 Gzip命令通常与tar命令一起使用。 我们将仅提供要压缩的文件。 在此示例中,我们将压缩thefile.txt 。 输出文件名将与只是添加.gz扩展名相同。

$ gzip thefile.txt
Compress File
Compress File
压缩档案

使用gzip命令列出压缩文件的内容(List Compressed File Contents with gzip Command)

Compressed file contents can be listed without decompressing them. We will use -l option. In the example, we want to list thefile.txt.gz compressed file settings. There is also information about compressed size,  file ratio, uncompressed_name, etc.

可以列出压缩文件的内容而无需将其解压缩。 我们将使用-l选项。 在示例中,我们要列出file.txt.gz压缩文件设置。 还提供有关压缩大小,文件比率,uncompressed_name等的信息。

$ gzip -l thefile.txt.gz

gzip压缩率更高 (Higher Compression Rate with gzip)

There are levels that are used to set compression ration, compressed file size, and compression duration. Higher-level compression will need more compression time but generally creates less file size. This is a trade-off. We will use -9 or --best options to specify.

有一些级别用于设置压缩率,压缩文件大小和压缩持续时间。 更高级别的压缩将需要更多的压缩时间,但通常会减少文件大小。 这是一个权衡。 我们将使用-9--best选项来指定。

$ gzip -9 thefile.txt
Higher Compression Rate
Higher Compression Rate
更高的压缩率

使用gzip更快地压缩(Faster Compression with gzip)

Another option for compression is faster compression. Actually this is the reverse of the higher compression rate. The compression duration will be less but the size will be higher than the default compression rate. We will use -1 or --fast .

压缩的另一种选择是更快的压缩。 实际上,这与较高的压缩率相反。 压缩持续时间将更短,但大小将大于默认压缩率。 我们将使用-1--fast

$ gzip --fast thefile.txt
Faster Compression
Faster Compression
压缩更快

解压文件(Decompress File)

Files can be decompressed with gunzip command or with -d parameter. gunzip is actually the alias of gzip -d .

可以使用gunzip命令或-d参数解压缩文件。 gunzip实际上是gzip -d的别名。

$ gzip -d thefile.txt.gz
Decompress File
Decompress File
解压文件
LEARN MORE  7z Command Tutorial With Examples To Compress And Extract Files In Linux
了解更多7z命令教程,并提供在Linux中压缩和提取文件的示例

翻译自: https://www.poftut.com/gzip-command-tutorial-examples-linux/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值