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
本文轉自 主内安詳 51CTO部落格,原文連結:http://blog.51cto.com/zhuneianxiang/2058112,如需轉載請自行聯系原作者