linux 中 gzip命令设置压缩等级

 

001、生成测试文件

[root@pc1 test]# ls
[root@pc1 test]# seq -f %010g 10000000 > a.txt             ## 测试文件
[root@pc1 test]# ll -h
total 113M
-rw-r--r--. 1 root root 113M Jan  9 12:03 a.txt            ## 测试文件 113Mb

 

002、gzip不同的压缩等级,压缩等级可以设置为1-9,最低为1, 最高为9

[root@pc1 test]# ls
a.txt
[root@pc1 test]# ll -h
total 113M
-rw-r--r--. 1 root root 113M Jan  9 12:03 a.txt
[root@pc1 test]# gzip -1 -c a.txt > 1.gz            ## 设置最低压缩等级为1
[root@pc1 test]# gzip -2 -c a.txt > 2.gz
[root@pc1 test]# gzip -4 -c a.txt > 4.gz
[root@pc1 test]# gzip -9 -c a.txt > 9.gz            ## 设置最高压缩等级为9
[root@pc1 test]# ls
1.gz  2.gz  4.gz  9.gz  a.txt
[root@pc1 test]# ll -h                              ## 比较不同压缩等级后文件的大小
total 135M
-rw-r--r--. 1 root root 7.0M Jan  9 12:09 1.gz
-rw-r--r--. 1 root root 7.0M Jan  9 12:09 2.gz
-rw-r--r--. 1 root root 4.7M Jan  9 12:09 4.gz
-rw-r--r--. 1 root root 3.8M Jan  9 12:10 9.gz
-rw-r--r--. 1 root root 113M Jan  9 12:03 a.txt

 。

 

posted @ 2024-01-08 12:08  小鲨鱼2018  阅读(79)  评论(0编辑  收藏  举报