1. 程式人生 > >6.5 zip壓縮工具;6.6 tar打包;6.7 打包並壓縮

6.5 zip壓縮工具;6.6 tar打包;6.7 打包並壓縮

列表 com 安裝 zip壓縮 tar打包 size min http 目錄名

6.5 zip壓縮工具

yum安裝zip壓縮工具:

[root@hao-01 ~]# yum install -y zip

1. zip壓縮文件zip 壓縮文件名 原文件

[root@hao-01 ~]# zip hao.txt.zip hao.txt

2. zip壓縮目錄zip -r 壓縮目錄名 原目錄

[root@hao-01 ~]# zip -r mulu1.zip mulu

yum安裝zip解壓工具:

[root@hao-01 ~]# yum install -y unzip

3. zip解壓文件unzip .zip壓縮文件

[root@hao-01 ~]# unzip hao.txt.zip

技術分享圖片技術分享圖片

4. zip

解壓文件,同時解壓到指定路徑

unzip .zip壓縮文件 -d 解壓指定路徑

[root@hao-01 ~]# unzip hao.txt.zip -d /tmp

5. zip解壓目錄unzip .zip目錄壓縮包

[root@hao-01 ~]# unzip mulu.zip

6. zip解壓目錄,同時解壓到指定路徑

unzip .zip目錄壓縮包 -d 解壓指定路徑

[root@hao-01 ~]# unzip mulu.zip -d /tmp

7. 列出zip目錄壓縮包 文件列表

unzip -l .zip目錄壓縮包

[root@hao-01 ~]# unzip -l mulu.zip

6.6 tar打包

1. tar打包目錄tar -cvf 目錄包名 原目錄

(v 的作用,可視打包過程,可以不添加!)

[root@hao-01 ~]# tar -cvf mulu.tar mulu1

2. tar解包.tar包tar -xvf .tar包

[root@hao-01 ~]# tar -xvf mulu.tar

3. tar同時打包目錄文件: tar -cvf 目錄包名 原目錄 文件

[root@hao-01 ~]# tar -cvf mulu.tar mulu hao.txt

4. 查看.tar目錄包 文件列表: tar -tf tar目錄包

[root@hao-01 ~]#

tar -tf mulu.tar

5. tar打包目錄,同時過濾目錄中的文件目錄不進行打包!

tar -cvf 目錄包名 --exclude 過濾文件 --exclude 過濾目錄 原目錄

[root@hao-01 ~]# tar -cvf mulu.tar --exclude 22.txt --exclude mulu3 mulu

6. tar打包目錄,同時過濾目錄中的所有後綴帶有.txt的文件 不進行打包!

tar -cvf 目錄包名 --exclude ".txt" 原目錄

[root@hao-01 ~]# tar -cvf mulu.txt --exclude ".txt" mulu

6.7 打包並壓縮

tar打包並gzip壓縮

1. tar打包gzip壓縮

tar -zcvf .tar.gz打包壓縮包名 文件 原目錄

[root@hao-01 ~]# tar -zcvf mulu.tar.gz hao.txt mulu

2. gzip解壓縮tar解包

tar -zxvf .tar.gz打包壓縮包

[root@hao-01 ~]# tar -zxvf mulu.tar.gz

3. 列出.tar.gz打包壓縮包 文件列表:

tar -tf .tar.gz打包壓縮包

[root@hao-01 ~]# tar -tf mulu1.tar.gz

tar打包並bzip2壓縮

1. tar打包bzip2壓縮

tar -jcvf .tar.bz2打包壓縮包名 文件 原目錄

[root@hao-01 ~]# tar -jcvf mulu.tar.bz2 hao.txt mulu

2. gzip解壓縮bzip2解包

tar -jxvf .tar.bz2打包壓縮包

[root@hao-01 ~]# tar -jxvf mulu.tar.bz2

3. 列出.tar.bzip2打包壓縮包 文件列表:

tar -tf .tar.bz2打包壓縮包

[root@hao-01 ~]# tar -tf mulu1.tar.bz2

tar打包並xz壓縮

1. tar打包並xz壓縮

tar -Jcvf .tar.xz打包壓縮包名 文件 原目錄

[root@hao-01 ~]# tar -Jcvf mulu.tar.xz hao.txt mulu

2. gzip解壓縮並xz解包

tar -Jxvf .tar.xz打包壓縮包

[root@hao-01 ~]# tar -Jxvf mulu.tar.xz

3. 列出.tar.xz打包壓縮包 文件列表:

tar -tf .tar.xz打包壓縮包

[root@hao-01 ~]# tar -tf mulu1.tar.xz


6.5 zip壓縮工具;6.6 tar打包;6.7 打包並壓縮