Zip压缩

[root@binbinlinux ~]# zip 12.txt.zip 12.txt     zip压缩命令  

  adding: 12.txt (deflated 70%)

[root@binbinlinux ~]# ls

0.txt   123.txt     222              install.log.syslog

1       12.txt      234              test.txt

111     12.txt.zip  anaconda-ks.cfg  tmp

1234.1  1.txt       install.log      yun

[root@binbinlinux ~]# unzip 12.txt.zip    解压缩命令

Archive:  12.txt.zip

replace 12.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y

  inflating: 12.txt

[root@binbinlinux ~]# zip -r 1.zip 1     压缩文件-r  zip可以解压文件

  adding: 1/ (stored 0%)

  adding: 1/2/ (stored 0%)

  adding: 1/2/3/ (stored 0%)

[root@binbinlinux ~]# du -sh 1

12K     1

[root@binbinlinux ~]# du -sh 1.zip

4.0K    1.zip

[root@binbinlinux ~]# ls         zip 不管是文件还是文档解压之后都不消失

0.txt   123.txt     1.zip    anaconda-ks.cfg     tmp

1       12.txt      222      install.log         yun

111     12.txt.zip  222.zip  install.log.syslog

1234.1  1.txt       234      test.txt

[root@binbinlinux ~]# unzip 222.zip -d/boot    解压文件-d选项 的写法

Archive:  222.zip

   creating: /boot/111/

   creating: /boot/111/23/

 extracting: /boot/111/23/22.txt

  inflating: /boot/111/123.txt

     Tar  打包工具详解

[root@binbinlinux ~]# tar -cvf 4.tar 222 234 0.txt    tar打包多个文件或者文档命令

222/

234/

234/222/

234/123.txt

0.txt

[root@binbinlinux ~]# ls        查看多了个4.tar

0.txt  111     123.txt  1.txt  234    anaconda-ks.cfg  install.log.syslog  tmp

1      1234.1  12.txt   222    4.tar  install.log      test.txt            yun

[root@binbinlinux ~]# du -sh 4.tar   比较大小   没有改变

32K     4.tar

[root@binbinlinux ~]# du -sh 222 234 0.txt    比较大小 并没有改变

4.0K    222

28K     234

4.0K    0.txt

[root@binbinlinux ~]# tar -tf 4.tar  查看目录下的打包的文件 文档

222/

234/

234/222/

234/123.txt

0.txt

[root@binbinlinux ~]# tar -xvf 4.tar   解包文件文档  命令

222/

234/

234/222/

234/123.txt

0.txt

[root@binbinlinux ~]# ls

0.txt  111     123.txt  1.txt  234    anaconda-ks.cfg  install.log.syslog  tmp

1      1234.1  12.txt   222    4.tar  install.log      test.txt            yun

[root@binbinlinux ~]# tar -C /boot/ -xvf 4.tar   解包指定目录

222/

234/

234/222/

234/123.txt

0.txt

Tar打包和压缩并用

 

 

[root@binbinlinux ~]# tar -zcvf 1.tar.gz 222 234   tar打包用gzip打包  命令写法

222/

234/

234/222/

234/123.txt

[root@binbinlinux ~]# ls

0.txt  111     123.txt  1.tar.gz  222  4.tar            install.log         test.txt  yun

1      1234.1  12.txt   1.txt     234  anaconda-ks.cfg  install.log.syslog  tmp

[root@binbinlinux ~]# du -sh 1.tar.gz   比较大小

8.0K    1.tar.gz

[root@binbinlinux ~]# tar -zxvf 1.tar.gz     tar解压gzip的命令

222/

234/

234/222/

234/123.txt

[root@binbinlinux ~]# tar -tf 1.tar.gz    也支持tf查看文件列表  

222/

234/

234/222/

234/123.txt

[root@binbinlinux ~]# tar -C /boot/ -zxvf 1.tar.gz   也支持在解包的时候指定目录

[root@binbinlinux ~]# tar -jcvf 1.tar.bz2 111 222    以bzip2打包

111/

111/23/

111/23/22.txt

111/123.txt

222/

[root@binbinlinux ~]# tar -Jcvf 1.tar.xz 111 222   以xz打包命令

111/

111/23/

111/23/22.txt

111/123.txt

222/

[root@binbinlinux ~]# tar -tf 1.tar.bz2        tar -tf查看文件列表

111/

111/23/

111/23/22.txt

111/123.txt

222/

[root@binbinlinux ~]# tar -tJf 1.tar.xz         tar -tJf 1.tar.xz 查看xz打包列表

111/

111/23/

111/23/22.txt

111/123.txt

222/

[root@binbinlinux ~]# tar -jxvf 1.tar.bz2   解压bz2的 命令

111/

111/23/

111/23/22.txt

111/123.txt

222/

[root@binbinlinux ~]# tar -Jxvf 1.tar.xz     解压xz的命令

111/

111/23/

111/23/22.txt

111/123.txt

222/

[root@binbinlinux ~]# tar -zxvf 1.tar.gz   解压gz的命令

222/

234/

234/222/

234/123.txt

[root@binbinlinux ~]# touch 111/23/zhaobin   创建个文件

[root@binbinlinux ~]# tree 111

111

├── 123.txt

└── 23

    ├── 22.txt

    └── zhaobin

 

1 directory, 3 files

[root@binbinlinux ~]# tar --exclude 22.txt -cvf 111.tar 111  过滤掉不向打包的文件命令

111/

111/23/

111/23/zhaobin

111/123.txt

[root@binbinlinux ~]# tar -tf 111.tar   查看打包列表

111/

111/23/

111/23/zhaobin

111/123.txt

[root@binbinlinux ~]# gz: tar -zcvf 1.tar.gz 111 222 ; tar -zxvf 1.tar.gz^C   用法详解

[root@binbinlinux ~]# bzip2 : tar -jcvf 1.tar.bz2 111 222; tar -jxvf 1.tar.bz2^C

[root@binbinlinux ~]# xz : tar -Jcvf 1.tar.xz 111 222 ; tar -Jxvf 1.tarxz^C

[root@binbinlinux ~]# tar -tf 1.tar.gz 1.tar.bz2^C

[root@binbinlinux ~]# tar -tJf  1.tar.xz^C