linux命令gunzip_Linux gunzip命令示例教程

本文介绍了Linux中gzip和gunzip命令的使用,包括如何解压缩文件、保留压缩文件、强制解压缩、查看压缩文件信息以及递归解压缩。gzip是一个常用的压缩工具,gunzip则专门用于解压缩.gz文件。使用gunzip的-k选项可以在解压缩后保留源文件,-f选项用于强制解压缩,而-t选项可检查文件的完整性和有效性。递归解压缩可以使用-r选项对目录中的所有.gz文件进行操作。
摘要由CSDN通过智能技术生成
linux命令gunzip

linux命令gunzip

.gz of gzip is very popular compression format used in Linux echo system. It is old compression algorithm but provides efficiency and speed during compression and decompression operations. Compression is very efficient file types like documents, text, some images etc. gzip compression algorithm also used in HTTP protocol to reduce traffic bandwidth.

gzip .gz是Linux回声系统中非常流行的压缩格式。 它是旧的压缩算法,但是在压缩和解压缩操作期间提供了效率和速度。 压缩是非常有效的文件类型,例如文档,文本,某些图像等gzip压缩算法也用于HTTP协议中以减少流量带宽。

用gzip命令解压缩文件 (Decompress Files with gzip Command)

We can use gzip tool in order to decompress a .gz file. As we know there is single gzip library which is used by different commands and scripts. In the following examples we will completely use gunzip command. In this example we will decompress file named myinput.py.gz

我们可以使用gzip工具来解压缩.gz文件。 众所周知,只有一个gzip库可供不同的命令和脚本使用。 在以下示例中,我们将完全使用gunzip命令。 在此示例中,我们将解压缩名为myinput.py.gz文件。

$ gzip -d myinput.py.gz

用gunzip命令解压缩 (Decompress with gunzip Command)

gunzip command provides more simpler usage than gzip command. Because it is designed to decompress we do not need to provide any option. We will just issue the gunzip command and the file name like below.

gunzip命令比gzip命令提供更简单的用法。 因为它旨在解压缩,所以我们不需要提供任何选项。 我们将只发出gunzip命令和如下文件名。

$ gunzip myinput.py.gz

解压缩后保留压缩和解压缩的文件 (Keep Compressed and Decompressed File After Decompress)

gunzip will remote compressed files after successfully decompress operation by default. If we need compressed file in the future we can avoid this behavior with -k option which means “keep this file after decompression”.

默认情况下, gunzip将在成功解压缩操作后远程压缩文件。 如果将来需要压缩文件,可以使用-k选项避免这种情况,这意味着“解压缩后保留此文件”。

$ gunzip -k myinput.py.gz

强制解压缩 (Decompress Forcibly)

Some times we can decompression with gunzip can create issues. This can prevent the compression because of created errors or warning. This errors and warning will prevent to complete decompression. We can provide -f force option which will complete decompression event some errors or warnings occurs.

有时我们可以用gunzip进行减压可能会造成问题。 这样可以避免由于创建的错误或警告而导致的压缩。 此错误和警告将阻止完成减压。 我们可以提供-f force选项,该选项将完成减压事件,并发生一些错误或警告。

$ gunzip -f myinput.py.gz

显示有关压缩文件的信息 (Display Information About Compressed File)

Compressed files will have some attributes related with compression. We may need to list these attributes in order to get more information about the compression. We can list these attributed with  -l option.

压缩文件将具有一些与压缩有关的属性。 为了获得有关压缩的更多信息,我们可能需要列出这些属性。 我们可以使用-l选项列出这些属性。

$ gunzip -l myinput.py.gz
Display Information About Compressed File
Display Information About Compressed File
显示有关压缩文件的信息

The following compression related attributes will be listed.

将列出以下与压缩有关的属性。

  • `Compressed Size` will show compressed file size

    “压缩大小”将显示压缩文件的大小
  • `Uncompressed Size` will show uncompressed file size

    `Uncompressed Size`将显示未压缩的文件大小
  • `Ratio` will show the compression ratio by dividing compressed size to uncompressed size

    “比率”将通过将压缩大小除以未压缩大小来显示压缩率
  • `Uncompressed Filename` will show filename in the archive.

    “未压缩的文件名”将在档案中显示文件名。
LEARN MORE  What Is GZ File Type or Extension? How To Create, Extract and Open Gz File?
了解更多什么是GZ文件类型或扩展名? 如何创建,提取和打开Gz文件?

递归解压缩 (Decompress Recursively)

As we can compress recursively files in directories we may need to decompress them. Decompressing one by one entering to the directory is not feasibly. So we can decompress them recursively by using -r option. We will decompress all gz file in the directory named oldbackup.

由于我们可以递归压缩目录中的文件,因此可能需要解压缩它们。 不能一一解压进入目录。 因此,我们可以使用-r选项来递归地解压缩它们。 我们将解压缩名为oldbackup的目录中的所有gz文件。

$ gzip -r oldbackup/

检查压缩文件的完整性和有效性 (Check Compressed File Integrity and Validity)

Some file get corrupted during compression or after compression. If we try to decompress them we will get some warnings or errors. We can check their integrity and validity with -t option which means “test the .gz file”.

某些文件在压缩过程中或压缩后会损坏。 如果我们尝试解压缩它们,我们将收到一些警告或错误。 我们可以使用-t选项检查它们的完整性和有效性,这意味着“测试.gz文件”。

$ gzip -t oldbackup/

$ gzip -t oldbackup /

关于解压缩操作的详细输出 (Verbose Output About Decompress Operation)

Up to know we have not put a lot of screenshots because gzipcommand rarely output to the console. But if we need more information about the current operation we can use -v option to print a lot of information.

众所周知,由于gzip命令很少输出到控制台,因此我们并没有放置很多屏幕截图。 但是,如果我们需要有关当前操作的更多信息,则可以使用-v选项来打印很多信息。

$ gunzip -v -r oldbackup/
Verbose Output About Decompress Operation
Verbose Output About Decompress Operation
关于解压缩操作的详细输出

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

linux命令gunzip

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值