这一章只讨论无损压缩
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