The commpression command in the linux (gzip , tar)

There was a test when you commpression one file repeatly:

➜  ~  ls -al test
-rw-r--r--@ 1 liugang  staff  3180 11 26 18:04 test
➜  ~  gzip test
➜  ~  ls -al test.gz
-rw-r--r--@ 1 liugang  staff  842 11 26 18:04 test.gz
➜  ~  mv test.gz test
➜  ~  gzip test
➜  ~  ls -al test.gz
-rw-r--r--@ 1 liugang  staff  870 11 26 18:04 test.gz
➜  ~  mv test.gz test
➜  ~  gzip test
➜  ~  ls -al test.gz
-rw-r--r--@ 1 liugang  staff  898 11 26 18:04 test.gz
➜  ~  mv test.gz test
➜  ~  gzip test
➜  ~  ls -al test.gz
-rw-r--r--@ 1 liugang  staff  926 11 26 18:04 test.gz
➜  ~  mv test.gz test
➜  ~  gzip test
➜  ~  ls -al test.gz
-rw-r--r--@ 1 liugang  staff  948 11 26 18:04 test.gz
➜  ~  mv test.gz test
➜  ~  gzip test
➜  ~  ls -al test.gz
-rw-r--r--@ 1 liugang  staff  976 11 26 18:04 test.gz
➜  ~  mv test.gz test
➜  ~  gzip -9 test
➜  ~  ls -al test.gz
-rw-r--r--@ 1 liugang  staff  1004 11 26 18:04 test.gz

For the result below , we can find that , only the first compression can reduce the file size , Then compress the gziped file will increse the size of this file.

The gzip command we usually used :

#compress the file
gzip filename
#display the compressed file
gzcat filename.gz
#uncompress file
gzip -d filename

#eg: compress the file use the best compress alog , and stag the origin file
gzip -9 -c filename > filename.gz

The tar command we usually used :

#pack and compress
tar -zcvf file.tar.gz dirname
#uncompress
tar -zxvf file.tar.gz
#list the files in the gz file
tar -ztvf file.tar.gz
#only uncompress one file in the .gz file
tar -zxvf file.tar.gz gzdir/filename
#uncompre  .gz file to specify dir
tar -zxvf file.tar.gz -C dirname


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值