linux基础学习——linuxfun第八章文件压缩

这一章只讨论无损压缩

1.关键词:gzip

gzip <文件> 可以直接压缩文件,压缩后文件会多一个扩展名.gz

ls -l services 
-rw-r--r-- 1 lilyeggy lilyeggy 14464 5月  11 16:00 services
gzip services 
ls -l services.gz 
-rw-r--r-- 1 lilyeggy lilyeggy 5903 5月  11 16:00 services.gz

2.关键词:zmore(相当于文件的more操作)

压缩后的文件无法使用cat,more,head,tail,grep操作
zmore <文件> 可以查看文件信息

3.关键词:zcat

zcat <文件名> | head -n/tail -n
可以查看前n行或者后n行内容

zcat services.gz | tail -4
tfido		60177/tcp			# fidonet EMSI over telnet
fido		60179/tcp			# fidonet EMSI over TCP

# Local services

4.关键词:zgrep

zgrep <关键词><文件名>
找寻文件中包含关键词的行

5.关键词:gzip-l

gzip -l <文件名> 可以显示文件解压缩后的大小

gzip -l all.txt.gz 
         compressed        uncompressed  ratio uncompressed_name
             332067             2903154  88.6% all.txt

6.关键词:gunzip

gunzip可以解压文件

gzip -l services.gz 
         compressed        uncompressed  ratio uncompressed_name
               5903               14464  59.4% services

ls -l services.gz 

-rw-r--r-- 1 lilyeggy lilyeggy 5903 5月  11 16:00 services.gz

gunzip services.gz

ls -l services 

-rw-r--r-- 1 lilyeggy lilyeggy 14464 5月  11 16:00 services

7.关键词:bzip

bzip也可压缩文件,bzip压缩比gzip慢但是压缩的更小,同时也有以b开头的bzcat,bunzip,bzmore操作

bzip2 services
ls -l services.bz2
-rw-r--r-- 1 lilyeggy lilyeggy 5624 5月  11 16:00 services.bz2

bzcat services.bz2 | tail -4
tfido		60177/tcp			# fidonet EMSI over telnet
fido		60179/tcp			# fidonet EMSI over TCP

# Local services

bunzip2 services.bz2 

ls -l services 
-rw-r--r-- 1 lilyeggy lilyeggy 14464 5月  11 16:00 services

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值