现在gzip(gunzip) 已经可以解压缩 compress,zip,gzip 所压缩的文件
gzip 压缩后的文件的后缀为.gz
常用选项;
-c :将压缩的数据输出到屏幕上,可以重定向来处理
-d : 解压缩选项
-t : 检验一个压缩文件的一致性,压缩文档有没有错误
-v : 显示压缩文档/原压缩文档的压缩比
-# : 压缩等级 -1 最快 压缩比最差,-9 最慢 当压缩比最好。预设-6
zcat 能够读取compress gzip压缩的文档。
bzip2 是的参数和gzip差不多 bzip2 是为了取代gzip的
-k 保存源文件
-z 压缩的参数
-c -v -# 都和上面的一样
bzcat 来查看
tar :
[root@Server1 perllearn]#tar -cjvf perllearn.bz2 /root/perllearn/chapter2/ /root/perllearn/chapter4/
tar: 从成员名中删除开头的“/”
/root/perllearn/chapter2/
/root/perllearn/chapter2/write_ten.pl
/root/perllearn/chapter2/timeout.pl
/root/perllearn/chapter2/read_three.pl
/root/perllearn/chapter2/kill_oneself.pl
/root/perllearn/chapter4/
/root/perllearn/chapter4/tcl_echo_cli1.pl
后面加多个路径 这里删除/是为了安全 ,因为解压缩时可以解压到任意位置 而不是覆盖原来的位置。
可以加选项-P 让他保留。
[root@Server1 perllearn]#tar -xjvf perllearn.bz2 root/perllearn/chapter2/write_ten.pl -O >./test.pl
root/perllearn/chapter2/write_ten.pl
把目录路径去掉.
-O, --to-stdout
extract files to standard output
extract files to standard output
[root@Server1 perllearn]#tar -cvf - /root/perllearn/chapter4/* | tar -xvf -
tar: 从成员名中删除开头的“/”
/root/perllearn/chapter4/tcl_echo_cli1.pl
root/perllearn/chapter4/tcl_echo_cli1.pl
边压缩边解压 可以将- 想象成缓冲区。先压缩到缓冲区 在重缓冲区解压。