安装zip
yum install zip unzip
用zip进行压缩
[root@mio-test ~]# zip test.zip ./temp/
解压ZIP文件
unzip test.zip
-r 进行递归压缩
[root@mio-test ~]# zip -r test.zip ./temp/ updating: temp/ (stored 0%) adding: temp/img_8.jpg (deflated 0%) adding: temp/img_1.jpg (deflated 0%) adding: temp/img_3.jpg (deflated 0%) adding: temp/1.txt (deflated 26%) adding: temp/2.txt (deflated 13%) adding: temp/img_6.jpg (deflated 0%) adding: temp/1 (deflated 24%) adding: temp/img_11.jpg (deflated 0%) adding: temp/img_2.jpg (deflated 0%) adding: temp/big_file (deflated 100%) adding: temp/text.dat (deflated 100%) adding: temp/img_6.jpg_copy (deflated 0%) adding: temp/img_4.jpg (deflated 0%) adding: temp/2 (deflated 100%) adding: temp/img_9.jpg (deflated 0%) adding: temp/img_10.jpg (deflated 0%) adding: temp/aaa/ (stored 0%) adding: temp/img_7.jpg (deflated 0%) adding: temp/del.sh (deflated 30%) adding: temp/rename.sh (deflated 14%) adding: temp/img_5.jpg (deflated 0%) adding: temp/1v2000000 (deflated 100%) adding: temp/sdsds6.jpg_copy (deflated 0%)
-u 更新ZIP文件
[root@mio-test ~]# zip -r test.zip -u ./temp/
-d 从zip中删除文件
[root@mio-test ~]# zip -d test.zip temp/2 deleting: temp/2
-l 列出zip文件中的内容
[root@mio-test ~]# unzip -l test.zip Archive: test.zip Length Date Time Name --------- ---------- ----- ---- 0 08-22-2014 18:18 temp/ 1570847 08-22-2014 16:19 temp/img_8.jpg 1714806 08-22-2014 16:19 temp/img_1.jpg 2361142 08-22-2014 16:18 temp/img_3.jpg 34 08-22-2014 17:07 temp/1.txt 16 08-22-2014 17:10 temp/2.txt 2607145 08-22-2014 16:19 temp/img_6.jpg 34 08-22-2014 17:02 temp/1 1464239 08-22-2014 16:18 temp/img_11.jpg 1995257 08-22-2014 16:18 temp/img_2.jpg 1000000 08-21-2014 18:00 temp/big_file 1000000 08-22-2014 16:53 temp/text.dat 2607145 08-22-2014 17:26 temp/img_6.jpg_copy 1985684 08-22-2014 16:19 temp/img_4.jpg 2218599 08-22-2014 16:18 temp/img_9.jpg 1460900 08-22-2014 16:19 temp/img_10.jpg 0 08-22-2014 18:18 temp/aaa/ 1692146 08-22-2014 16:19 temp/img_7.jpg 202 08-22-2014 18:15 temp/del.sh 115 08-22-2014 16:27 temp/rename.sh 2330176 08-22-2014 16:19 temp/img_5.jpg 1000000 08-21-2014 18:07 temp/1v2000000 2607145 08-22-2014 17:26 temp/sdsds6.jpg_copy --------- ------- 29615632 23 files