6.3-4 zip、unzip
生活随笔
收集整理的這篇文章主要介紹了
6.3-4 zip、unzip
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
zip:打包和壓縮文件
zip壓縮格式是Windows與Linux等多平臺通用的壓縮格式。和gzip命令相比,zip命令壓縮文件不僅不會刪除源文件,而且還可以壓縮目錄。zip命令的參數(shù)選項(xiàng)及說明
-r?? ?將指定目錄下的所有文件和子目錄一并壓縮 -x?? ?壓縮文件時排除某個文件 -q?? ?不顯示壓縮信息壓縮文件
[root@cs6 tmp]# cp /etc/services . [root@cs6 tmp]# ll -h services -rw-r--r--. 1 root root 626K May 13 00:35 services[root@cs6 tmp]# zip services.zip ./services #<==格式:zip 壓縮包名 被壓縮的文件。adding: services (deflated 80%) #<==deflated壓縮率。 [root@cs6 tmp]# ll -h services* -rw-r--r--. 1 root root 626K May 13 00:35 services -rw-r--r--. 1 root root 125K May 13 00:38 services.zip壓縮目錄
[root@cs6 tmp]# cd / [root@cs6 /]# zip tmp.zip ./tmp/adding: tmp/ (stored 0%) [root@cs6 /]# zip -r tmp.zip ./tmp/ updating: tmp/ (stored 0%)adding: tmp/anaconda-ks.cfg (deflated 38%)adding: tmp/install.log (deflated 71%)adding: tmp/yum.log (stored 0%)....adding: tmp/html/6.html (stored 0%)adding: tmp/html/10.html (stored 0%)adding: tmp/html/1.html (stored 0%)adding: tmp/html/8.html (stored 0%)adding: tmp/services.zip (stored 0%)adding: tmp/services (deflated 80%)排除壓縮
[root@cs6 /]# zip -r tmp.zip ./tmp/ -x tmp tmp/ tmp.zip [root@cs6 /]# zip -r tmp.zip ./tmp/ -x tmp/services.zip updating: tmp/ (stored 0%) updating: tmp/anaconda-ks.cfg (deflated 38%) updating: tmp/install.log (deflated 71%) updating: tmp/yum.log (stored 0%) updating: tmp/.ICE-unix/ (stored 0%) updating: tmp/lewen.log (deflated 50%) ...... updating: tmp/html/8.html (stored 0%) updating: tmp/services (deflated 80%) [root@cs6 /]#unzip:解壓zip文件
unzip命令可以解壓zip命令或其他壓縮軟件壓縮的zip格式的文件。 -l?? ?不解壓顯示壓縮包內(nèi)容 -o?? ?解壓時不提示是否覆蓋文件 -d?? ?指定解壓目錄 -v?? ?解壓時顯示詳細(xì)信息查看壓縮文件。
[root@cs6 /]# unzip -l tmp.zip Archive: tmp.zipLength Date Time Name --------- ---------- ----- ----0 05-13-2019 00:38 tmp/1092 05-05-2019 23:12 tmp/anaconda-ks.cfg8081 05-05-2019 23:12 tmp/install.log0 05-05-2019 23:10 tmp/yum.log0 05-11-2019 17:56 tmp/.ICE-unix/150 05-12-2019 22:54 tmp/lewen.log3384 05-05-2019 23:11 tmp/install.log.syslog9068168 05-12-2019 18:46 tmp/etc.tar.gz0 05-12-2019 18:19 tmp/html/......0 05-12-2019 18:19 tmp/html/6.html0 05-12-2019 18:19 tmp/html/10.html0 05-12-2019 18:19 tmp/html/1.html0 05-12-2019 18:19 tmp/html/8.html127362 05-13-2019 00:38 tmp/services.zip641020 05-13-2019 00:35 tmp/services --------- -------9849257 23 files常規(guī)解壓文件的例子
[root@cs6 /]# unzip tmp.zip Archive: tmp.zip replace tmp/anaconda-ks.cfg? [y]es, [n]o, [A]ll, [N]one, [r]ename: yinflating: tmp/anaconda-ks.cfg replace tmp/install.log? [y]es, [n]o, [A]ll, [N]one, [r]ename: yinflating: tmp/install.log replace tmp/yum.log? [y]es, [n]o, [A]ll, [N]one, [r]ename: y[root@cs6 /]# unzip -v tmp.zip #<==解壓時顯示一些信息。 Archive: tmp.zip Length Method Size Cmpr Date Time CRC-32 Name -------- ------ ------- ---- ---------- ----- -------- ----0 Stored 0 0% 05-13-2019 00:38 00000000 tmp/1092 Defl:N 679 38% 05-05-2019 23:12 0cd9b8ec tmp/anaconda-ks.cfg8081 Defl:N 2366 71% 05-05-2019 23:12 2254ab8c tmp/install.log150 Defl:N 75 50% 05-12-2019 22:54 6195ad09 tmp/lewen.log3384 Defl:N 569 83% 05-05-2019 23:11 0c331784 tmp/install.log.syslog 9068168 Defl:N 7955263 12% 05-12-2019 18:46 da37147b tmp/etc.tar.gz ......0 Stored 0 0% 05-12-2019 18:19 00000000 tmp/html/8.html127362 Stored 127362 0% 05-13-2019 00:38 859b286f tmp/services.zip641020 Defl:N 127196 80% 05-13-2019 00:35 33bd3343 tmp/services -------- ------- --- ------- 9849257 8213510 17% 23 files[root@cs6 /]# unzip -o tmp.zip #<==解壓時不提示是否覆蓋。 Archive: tmp.zipinflating: tmp/anaconda-ks.cfg inflating: tmp/install.log inflating: tmp/install.log.syslog inflating: tmp/etc.tar.gz ..... extracting: tmp/html/1.html extracting: tmp/html/8.html extracting: tmp/services.zip inflating: tmp/services指定解壓目錄解壓文件? ??
[root@cs6 /]# unzip -d /tmp tmp.zip #<==可以使用-d選項(xiàng)接目錄來指定解壓目錄 Archive: tmp.zipcreating: /tmp/tmp/inflating: /tmp/tmp/anaconda-ks.cfg inflating: /tmp/tmp/install.log extracting: /tmp/tmp/yum.log creating: /tmp/tmp/.ICE-unix/ .... extracting: /tmp/tmp/html/1.html extracting: /tmp/tmp/html/8.html extracting: /tmp/tmp/services.zip inflating: /tmp/tmp/services [root@cs6 /]# tree /tmp /tmp ├── anaconda-ks.cfg ├── etc.tar.gz ├── html │ ├── 10.html │ ├── 1.html │ ├── 2.html │ ├── 3.html │ ├── 4.html │ ├── 5.html │ ├── 6.html ....│ ├── services │ ├── services.zip │ └── yum.log └── yum.log7 directories, 36 files總結(jié)
以上是生活随笔為你收集整理的6.3-4 zip、unzip的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 6.5 scp:远程文件复制
- 下一篇: 6.1 tar:打包备份