2015/03/27   壓縮和解包

一、gzip壓縮和解包

     1. 壓縮;

[root@Centos1 ~]# gzip 2.txt

     2. 解包;

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

     3. 查看包壓縮的內容;

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

二、bzip壓縮和解包

     1. 壓縮;

[root@Centos1 ~]# bzip2 2.txt

     2. 解包;

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

     3. 查看壓縮包的內容;

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

三、zip壓縮和解包

     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

四、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          #查看包的內容
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章