2015/03/27 壓縮和解包

1、gzip壓縮和解包bash

     1. 壓縮;ide

[root@Centos1 ~]# gzip 2.txt

     2. 解包;
spa

[root@Centos1 ~]# gzip -d 2.txt.gz

     3. 查看包壓縮的內容;
orm

[root@Centos1 ~]# zcat 1.txt.gz

2、bzip壓縮和解包
ip

     1. 壓縮;it

[root@Centos1 ~]# bzip2 2.txt

     2. 解包;
class

[root@Centos1 ~]# bzip2 -d 2.txt.bz2

     3. 查看壓縮包的內容;
di

[root@Centos1 ~]# bzcat 2.txt.bz2

3、zip壓縮和解包
gzip

     1. 壓縮;文件

[root@Centos1 ~]# zip 2.zip 2.txt 
[root@Centos1 ~]# zip -r etc.zip /etc           #壓縮目錄

     2. 解包;

[root@Centos1 ~]# unzip etc.zip  
[root@Centos1 ~]# unzip -d /tmp etc.zip         #解壓到/tmp下

     3. 查看壓縮包的內容;

[root@Centos1 ~]# unzip -l etc.zip

4、tar壓縮和解包

     1. 壓縮

[root@Centos1 ~]# tar -zcvf 1.tar.zg /etc
[root@Centos1 ~]# tar -jcvf 1.tar.bz2 /etc
[root@Centos1 ~]# tar -cvf 1.tar /etc
[root@Centos1 ~]# tar -cvf 1.tar --exclude "*.sh" -exclude "*i386" /etc   
#exclude排除文件

     2. 解包

[root@Centos1 ~]# tar -zxvf 1.tar.zg
[root@Centos1 ~]# tar -jxvf 1.tar.bz2
[root@Centos1 ~]# tar -xvf 1.tar 
[root@Centos1 ~]# tar -xvf 1.tar  -C /tmp          #解壓到/tmp下

     3. 查看壓縮的內容

[root@Centos1 ~]# tar -tf 1.tar          #查看包的內容
相關文章
相關標籤/搜索