gzip -c 将输出写到标准输出上,并保留原文本
gzip * : 把当前目录中的每个文件压缩成.gz文件
[root@NB gzip]# lsmysql-bin.001712 mysql-bin.001712.tar mysql-bin.001835.tar zoom_x86_64.rpm [root@NB gzip]# gzip * [root@NB gzip]# ls mysql-bin.001712.gz mysql-bin.001835.tar.gz mysql-bin.001712.tar.gz zoom_x86_64.rpm.gz
gzip -dv * :把目录中每个压缩的文件解压,并列出说细的信息
[root@NB gzip]# gzip -dv *mysql-bin.001712.gz: 79.3% -- replaced with mysql-bin.001712mysql-bin.001712.tar.gz: 79.3% -- replaced with mysql-bin.001712.tarmysql-bin.001835.tar.gz: 78.6% -- replaced with mysql-bin.001835.tarzoom_x86_64.rpm.gz: 0.0% -- replaced with zoom_x86_64.rpm
同样可以这样,把当前目录下的所有文件压缩成.gz 文件-v是显示所有的过程:
[root@NB gzip]# gzip -v *mysql-bin.001712: 79.3% -- replaced with mysql-bin.001712.gzmysql-bin.001712.tar: 79.3% -- replaced with mysql-bin.001712.tar.gzmysql-bin.001835.tar: 78.6% -- replaced with mysql-bin.001835.tar.gzzoom_x86_64.rpm: 0.0% -- replaced with zoom_x86_64.rpm.gz
gzip -l *:显示每个压缩文件的内容并不解压:
[root@NB gzip]# gzip -l * compressed uncompressed ratio uncompressed_name 11410830 54998926 79.3% mysql-bin.001712 11411047 55009280 79.3% mysql-bin.001712.tar 4405058 20602880 78.6% mysql-bin.001835.tar 55545235 55568080 0.0% zoom_x86_64.rpm 82772170 186179166 55.5% (totals)
因为gzip只能单个文件的压缩,所以我们常会先用tar打包多个文件为一个文件,然后再用zip压缩:
[root@NB gzip]# lssql_lxsc[root@NB gzip]# tar -cvf sql_lxsc.tar sql_lxsc/[root@NB gzip]# lssql_lxsc sql_lxsc.tar[root@NB gzip]# gzip -v sql_lxsc.tar sql_lxsc.tar: 83.8% -- replaced with sql_lxsc.tar.gz[root@NB gzip]# lssql_lxsc sql_lxsc.tar.gz[root@NB gzip]# file sql_lxsc.tar.gz sql_lxsc.tar.gz: gzip compressed data, was "sql_lxsc.tar", from Unix, last modified: Sat Dec 3 17:31:39 2016当然没这么麻烦:[root@NB gzip]# lssql_lxsc[root@NB gzip]# tar -czvf sql_lxsc.tar.gz sql_lxsc/[root@NB gzip]# lssql_lxsc sql_lxsc.tar.gz[root@NB gzip]# file sql_lxsc.tar.gz sql_lxsc.tar.gz: gzip compressed data, from Unix, last modified: Sat Dec 3 17:34:10 2016