linux压缩命令gzip

Linux offers an array of tools for compressing and decompressing files. In this tutorial, we take a look at the Linux gzip command tool.

Linux提供了一系列用于压缩和解压缩文件的工具。 在本教程中,我们将研究Linux gzip命令工具。

Gzip is a file format as well as a software application which was created by Mark Adler and Jean-Loup Gailly and has been in use since the early Unix Systems.

Gzip是Mark Adler和Jean-Loup Gailly创建的一种文件格式以及一种软件应用程序,自早期Unix Systems以来就一直在使用。

Linux gzip command uses the (LZ77) Lempel-Ziv coding during its operations. Let’s dive in and see the various examples of how Gzip can be used.

Linux gzip命令在操作期间使用(LZ77)Lempel-Ziv编码。 让我们深入了解如何使用Gzip的各种示例。

使用Linux gzip命令压缩文件 (Compress a File using Linux gzip Command)

Compressing a file with gzip command is a walk in the park. Simply pass the file name as the argument as shown.

用gzip命令压缩文件是在公园散步。 只需将文件名作为参数传递即可,如图所示。

$ gzip [filename]

The final compressed file acquires a suffix .gz.

最终的压缩文件将获得后缀.gz

For example, I have 4 text files in my current working directory as shown below.

例如,我当前的工作目录中有4个文本文件,如下所示。

To compress file1.txt using gzip, the syntax will be.

要使用gzip压缩file1.txt ,语法将是。

$ gzip file1.txt

To view the compressed file, use the ls command.

要查看压缩文件,请使用ls命令。

Output

输出量

It’s worth noting that the original text file has now been compressed and bears the .gz compression suffix.

值得注意的是,原始文本文件现已压缩,并带有.gz压缩后缀。

强制gzip不替换/删除原始文件 (Force gzip not to replace/delete the original file)

As we have seen in the previous example, gzip replaces the original file and turns it into a compressed file.
However, you can opt to retain the original file using the -k option as shown.

正如我们在前面的示例中看到的那样,gzip替换了原始文件并将其转换为压缩文件。
但是,您可以选择使用-k选项保留原始文件,如图所示。

gzip -k [file-name]

For example, to compress file1.txt to a .gz file whie retaining the same file execute the command.

例如,要将file1.txt压缩为保留相同文件的.gz文件,请执行以下命令。

$ gzip -k file1.txt

Be sure to verify using the ls command and note that the original file1.txt file is still present.

确保使用ls命令进行验证,并注意原始的file1.txt文件仍然存在。

使用gzip递归压缩文件 (Recursively compress files using gzip)

To compress all files recursively inside a directory, use the -r option as shown.

要递归压缩目录中的所有文件,请使用-r选项,如图所示。

$ gzip -r *

For example, there are 4 text file inside the test folder as shown.

例如,如图所示, 测试文件夹中有4个文本文件。

To compress all the files at a go run:

要一次性压缩所有文件:

$ gzip -r *

Output

输出量

使用gzip解压缩文件 (Uncompress a file using gzip)

If you want to uncompress a file, use the -d option a shown in the syntax below.

如果要解压缩文件,请使用-d选项,语法如下所示。

$ gzip -d [compressed file-name]

For instance, to uncompress file1.txt.gz run:

例如,要解压缩file1.txt.gz,请运行:

$ gzip -d file1.txt.gz

Output

输出量

As you can see, the original compressed file disappears.

如您所见,原始压缩文件消失了。

列出使用gzip压缩文件的详细信息 (List details of a compressed file using gzip)

To list details of a compressed file make use of the -l option as shown.

要列出压缩文件的详细信息,请使用-l选项,如图所示。

$ gzip -l [compressed-file-name]

For example,

例如,

$ gzip -l file1.txt.gz

Output

输出量

如何调节gzip压缩的速度 (How to Regulate Speed of gzip Compression)

Gzip command also allows you to regulate the speed of compression. You can achieve this by specifying a hyphen (-) followed by a digit or number between 1 (Fastest) to 9 (Best). The default compression speed is 6.

Gzip命令还允许您调节压缩速度。 您可以通过指定连字符(-)后接1(最快)到9(最佳)之间的数字或数字来实现此目的。 默认压缩速度为6。

gzip -5 [file-name]

For instance:

例如:

gzip -5 file1.txt

You can use any digit/number between 1 and 9, where 1 denotes the fastest compression rate and 9 denotes the slowest compression rate but the most preferred.

您可以使用1到9之间的任何数字/数字,其中1表示最快的压缩率,而9表示最慢的压缩率,但最优选。

And that wraps up the gzip command usage. Feel free to share your thoughts on this. Your feedback is most welcome.

这样就结束了gzip命令的用法。 随时分享您的想法。 非常欢迎您提供反馈。

翻译自: https://www.journaldev.com/30260/linux-gzip-command-examples

linux压缩命令gzip

linux压缩命令gzip_Linux gzip命令示例相关推荐

  1. linux下压缩gz文件怎么打开,Linux压缩gz文件(gzip)

    Linux压缩gz文件(gzip)教程 Linux gzip命令详解 功能 用于压缩或解压缩一个 gz 压缩文件. 语法 gzip [options] file... 参数 参数 描述 options ...

  2. linux下gzip用法,Linux下tar和gzip命令的方法

    tar [选项] 压缩(解压缩)的文件名 选项:-c 建立新的归档文件 -r 向归档文件末尾追加文件 -x 从归档文件中解出文件 -O 将文件解开到标准输出 -v 处理过程中输出相关信息 -f 对普通 ...

  3. 压缩命令_Linux gzip命令:压缩文件或目录

    gzip 是 Linux 系统中经常用来对文件进行压缩和解压缩的命令,通过此命令压缩得到的新文件,其扩展名通常标记为".gz". 再强调一下,gzip 命令只能用来压缩文件,不能压 ...

  4. linux每日命令(1):gzip命令

    gzip是在Linux系统中经常使用的一个对文件进行压缩和解压缩的命令,既方便又好用. gzip不仅可以用来压缩大的.较少使用的文件以节省磁盘空间,还可以和tar命令一起构成Linux操作系统中比较流 ...

  5. gzp解压命令 linux_Linux gzip命令:压缩文件或目录

    gzip 是 Linux 系统中经常用来对文件进行压缩和解压缩的命令,通过此命令压缩得到的新文件,其扩展名通常标记为".gz". 再强调一下,gzip 命令只能用来压缩文件,不能压 ...

  6. Linux压缩与解压命令的使用

    压缩文件的格式种类很多,这里只介绍几种常见的压缩格式,比如 zip.tar.tar.gz.rar. 文章目录 ZIP zip unzip RAR rar a rar x GZIP gzip -r gz ...

  7. linux压缩与解压缩 tar命令

    linux解压 tar命令 tar命令 tar [-cxtzjvfpPN] 文件与目录 ....  参数:  -c :建立一个压缩文件的参数指令(create 的意思):  -x :解开一个压缩文件的 ...

  8. linux压缩一个文件的命令行,linux下用命令行解压缩文件

    tar -zxvf install_flash_player_11_linux.x86_64.tar.gz 这是最一般的做法,其中tar后面的参数"zxvf"其实每个字母都是可选的 ...

  9. linux 压缩 解压zip 命令

    将当前目录下的所有文件和文件夹全部压缩成test.zip文件,-r表示递归压缩子目录下所有文件 zip -r test.zip ./* 打包指定目录以及其子目录下的所有文件 zip -r test2. ...

最新文章

  1. 两个asp.net发送邮件类
  2. CMPP3.0 长短信实现方案
  3. Android属性动画 PropertyValuesHolder
  4. 【Boost】以boost::function和boost:bind取代虚函数
  5. 热插拔服务器电源维修,无需关停系统即可热插拔,TE Connectivity推出滑轨电源连接器...
  6. 如何升软件开发项目的利润
  7. 开发实现物理加速度移动_Cocos Creator 3D 物理模块介绍
  8. python 生成嵌套字典
  9. RX.AutoImage+Fluent Airpak v2.1
  10. 【UCSC Genome Browser】- ClinGen剂量敏感性分析
  11. 安装AutoCAD 2015提示net 4.5错误的解决方法
  12. 编码人大脑的5大小吃
  13. python曲线拟合准确度评估_使用Python SciPy量化曲线拟合的质量
  14. Win10邮箱管理QQ邮箱+163邮箱
  15. C语言uint8_t和char的区别,c – int8_t和uint8_t是char类型吗?
  16. 七、python基础:格式化占位符
  17. 汽车在线升级系统(OTA)开发浅析
  18. aws s3跨区复制文件
  19. android xml图片缩放,Android通过自定义ImageView控件实现图片的缩放和拖动的实现代码...
  20. 细说苹果电脑上不错的滤镜软件

热门文章

  1. FPGA中数的表示方法
  2. Vue.js 学习笔记 五 常用的事件修饰符
  3. vue.js基础知识篇(1):简介、数据绑定
  4. 项目需求:基于微信平台的拼团活动系统
  5. Cordova开发总结(插件篇)
  6. (匹配)Fire Net --hdu --1045
  7. java显示字母数字组合_Java字母加数字组合比较大小
  8. Javamysql语法转化oracle_MyBatis项目实战 快速将MySQL转换成Oracle语句
  9. myisam为什么比innodb查询快_mysql存储引擎之MyISAM 和 InnoDB的比较
  10. linux 777权限_认识Linux之Linux命令-用户、权限管理(8)