压缩解压缩介绍以及运用

 9月30日任务

6.1 压缩打包介绍linux

6.2 gzip压缩工具工具

6.3 bzip2压缩工具 spa

6.4 xz压缩工具 ip

 

6.1 压缩打包介绍打包

gzip压缩工具命名

  • gzip 1.txtgzip

  • gzip -d 1.txt.gz  /gunzip 1.txt.gz文件

  • gzip -# 1.txt          //#范围1-9 ,默认6co

  • 不能压缩目录new

  • zcat 1.txt.gz

  • gzip -c 1.txt >/root/1.txt.gz

  • gunzip -c /root/1.txt.gz > /tmp/1.txt.new

#gzip压缩解压缩运用

[root@zgxlinux-01 tmp]# find /etc/ -type f -name "*conf" -exec cat {} >> /tmp/d6z/1.txt \;   #查找etc下以conf结尾的文件而且追加到/d6z/1.txt中。
[root@zgxlinux-01 tmp]# du /tmp/d6z/1.txt 
236    /tmp/d6z/1.txt
[root@zgxlinux-01 d6z]# gzip 1.txt    #压缩文件1.txt
[root@zgxlinux-01 d6z]# ls
1.txt.gz
[root@zgxlinux-01 d6z]# du -sh 1.txt.gz 
64K    1.txt.gz
[root@zgxlinux-01 d6z]# gzip -d 1.txt.gz    #加压缩-d
[root@zgxlinux-01 d6z]# ls
1.txt
[root@zgxlinux-01 d6z]# gzip -c 1.txt > /tmp/zgx/1.txt.gz   #压缩文件到其余目录而且保留源文件
[root@zgxlinux-01 d6z]# ls
1.txt
[root@zgxlinux-01 d6z]# ls /tmp/zgx/
111  1.txt.gz
[root@zgxlinux-01 d6z]# gunzip -c /tmp/zgx/1.txt.gz > /tmp/d6z/2.txt    #解压缩打包文件后重命名且保留源文件
[root@zgxlinux-01 d6z]# ls
1.txt  2.txt

 

xz压缩工具

  • xz 1.txt /xz -z 1.txt

  • xz -d 1.txt.xz /unxz 1.txt.xz

  • xz -# 1.txt //#范围1-9 ,默认6

  • 不能压缩目录

  • xzcat 1.txt.xz

  • xz -c 1.txt > /root/1.txt.xz

  • xz -d -c /root/1.txt.xz >1.txt.new3

 

bzip2 压缩工具       #用法和gzip用法基本相同,但压缩比例比gzip更高。

  • bzip2 .1txt /bzip2 -z 1.txt

  • bzip2 -d 1.txt.bz2 /bunzip2 1.txt.bz2

  • bzip -# 1.txt //#范围1-9,默认9

  • 不能压缩目录

  • bzcat 1.txt.bz2

  • bzip2 -c 1.txt > /root/1.txt.bz2

  • bzip2 -c -d /root/1.txt.bz2 >/tmp/1.txt.new2

[root@zgxlinux-01 d6z]# bzip2 1.txt 
[root@zgxlinux-01 d6z]# ls
1.txt.bz2  2.txt
[root@zgxlinux-01 d6z]# du -sh 1.txt.bz2 
56K    1.txt.bz2
[root@zgxlinux-01 d6z]# bzip2 -d 1.txt.bz2 
[root@zgxlinux-01 d6z]# ls
1.txt  2.txt
[root@zgxlinux-01 d6z]# bzip2 1.txt 
[root@zgxlinux-01 d6z]# bunzip2 1.txt.bz2 
[root@zgxlinux-01 d6z]# ls
1.txt  2.txt

tar打包工具

  • tar -cvf 123.tar 123

  • tar -cvf aming.tar 1.txt 123

  • tar -xvf aming.tar

  • tar -tf aming.tar

  • tar -cvf aming.tar --exclude 1.txt --exclude 2 123

相关文章
相关标签/搜索