昨天推荐:每天学一个Linux命令(39):tar命令介绍gzip命令用于压缩文件,gzip和gunzip命令用于压缩文件压缩或展开GNUGZIP格式的文件。如果压缩文件名对于其文件系统而言太长,gzip将截断它。默认情况下,gzip将在新生成的压缩文件中保留原始文件名和时间戳等信息。语法格式gzip[OPTIONS][name]gunzip[OPTIONS][name]选项说明-a#使用ASCII文本模式-c#将输出写到标准输出,保持原文件不变。-d#解压文件-f#强制压缩文件-h#显示在线帮助信息-l#列出压缩文件的信息-L#显示版本和版权信息-n#压缩文件时,不保留原文件名和时间戳等属性信息-N#压缩文件时,保留原文件名和时间戳属性信息-q#不显示警告信息-r#递归处理,将指定目录下的所有文件和子目录一起处理-t#测试是否压缩压缩文件正确-v#显示命令执行过程信息-V#显示版本信息-<压缩效率>#压缩效率是1~9之间的一个值,默认值为“6”,指定值越高压缩率,应用实例越高。将当前目录下所有文件压缩成.gz包[root@centos7testdir]#gzip*[root@centos7testdir]#lltotal24-rw-r--r--1rootroot59Jan1612:15cest.txt.gz-rw-r--r--1rootroot57Jan1612:12cuttest.txt.gz-rw-r--r--1rootroot81Jan1609:55mingongge1.txt.gz-rw-r--r--1rootroot51Jan1603:36mingongge2.txt.gz-rw-r--r--1rootroot87Jan1609:59mingongge.txt.md5.gz-rw-r--r--1rootroot65Jan1610:19sort.cut.txt.gz解压当前目录下的每个压缩文件,并列出详细信息[root@centos7testdir]#gzip-dv*cest.txt.gz:77.8%--替换为cest.txtcuttest.txt.gz:73.5%--替换为cuttest.txtmingongge1.txt.gz:61.3%--替换为mingongge1.txtmingongge2.txt.gz:25.0%--替换用mingongge2.txtmingongge.txt.md5.gz:-4.1%--替换为mingongge.txt.md5sort.cut.txt.gz:19.0%--替换为sort.cut.txt[root@centos7testdir]#lltotal24-rw-r--r--1rootroot144Jan1612:15cest.txt-rw-r--r--1rootroot102Jan1612:12cuttest.txt-rw-r--r--1rootroot124Jan1609:55mingongge1.txt-rw-r--r--1rootroot24Jan1603:36mingongge2.txt-rw-r--r--1rootroot49Jan1609:59mingongge.txt.md5-rw-r--r--1rootroot42Jan1610:19sort.cut.txt详细显示当前目录下每个压缩文件的信息,但不解压文件[root@centos7testdir]#gzip-l*压缩的未压缩比uncompressed_name5914477.8%cest.txt5710273.5%cuttest.txt8112461.3%mingongge1.txt51242425.0%mingongge2.txt2.txt87494949-4.1%mingongge.txt.txt.txt.md5656542424219.0%.txt40048523.9%(totals)和tar命令的常用用法基本一致,都是属性文件压缩和解压命令
