扣丁學堂淺談Linux開發下如何利用unzip命令實現解壓多個檔案操作詳解
今天扣丁學堂 ofollow,noindex">Linux培訓 來給大家介紹一下關於在Linux下如何利用unzip命令實現解壓多個檔案的操作,下面我們通過示例程式碼來詳細的是介紹一下吧。

1、Linux中提示沒有unzip命令解決方法
如果你如法使用unzip命令解壓.zip檔案,可能是你沒有安裝unzip軟體,下面是安裝方法
命令:yumlist|grepzip/unzip#獲取安裝列表
安裝命令:yuminstallzip#提示輸入時,請輸入y;
安裝命令:yuminstallunzip#提示輸入時,請輸入y;
2、Linux下直接使用unzip*.zip解壓多個檔案會報錯
可以使用unzip'*.zip'或者unzip"*.zip"或者unzip\*.zip命令
或者使用forzin*.zip;dounzip$z;done執行解壓
如下可以看到當前目錄下有6個zip壓縮包檔案
[root@autoServerCOLLECTION]#ll-s
total24
4-rw-r--r--.1rootroot1681Sep1115:3800004.zip
4-rw-r--r--.1rootroot1325Sep1115:3800005.zip
4-rw-r--r--.1rootroot1540Sep1115:4300010.zip
4-rw-r--r--.1rootroot1392Sep1115:4300011.zip
4-rw-r--r--.1rootroot1541Sep1115:4800016.zip
4-rw-r--r--.1rootroot1390Sep1115:4800017.zip
使用unzip\*.zip命令進行解壓,可以看到6個檔案都解壓成功了
[root@autoServerCOLLECTION]#unzip\*.zip
Archive:00005.zip
inflating:GAB_ZIP_INDEX.xml
inflating:15366516000003-BASIC_1004.bcp
Archive:00010.zip
replaceGAB_ZIP_INDEX.xml?[y]es,[n]o,[A]ll,[N]one,[r]ename:n
inflating:15366518460006-SOURCE_1001.bcp
Archive:00016.zip
replaceGAB_ZIP_INDEX.xml?[y]es,[n]o,[A]ll,[N]one,[r]ename:A
inflating:GAB_ZIP_INDEX.xml
inflating:15366519060012-SOURCE_1001.bcp
Archive:00017.zip
inflating:GAB_ZIP_INDEX.xml
inflating:15366519080014-SOURCE_1002.bcp
Archive:00004.zip
inflating:GAB_ZIP_INDEX.xml
inflating:15366516000001-BASIC_1003.bcp
Archive:00011.zip
inflating:GAB_ZIP_INDEX.xml
inflating:15366518480008-SOURCE_1002.bcp
6archivesweresuccessfullyprocessed.
再檢視當前目錄已經有了解壓後的檔案
[root@autoServerCOLLECTION]#ll-s
total52
4-rw-r--r--.1rootroot294Sep1115:4015366516000001-BASIC_1003.bcp
4-rw-r--r--.1rootroot158Sep1115:4015366516000003-BASIC_1004.bcp
4-rw-r--r--.1rootroot104Sep1115:4515366518460006-SOURCE_1001.bcp
4-rw-r--r--.1rootroot80Sep1115:4515366518480008-SOURCE_1002.bcp
4-rw-r--r--.1rootroot104Sep1115:5015366519060012-SOURCE_1001.bcp
4-rw-r--r--.1rootroot80Sep1115:5015366519080014-SOURCE_1002.bcp
4-rw-r--r--.1rootroot1681Sep1115:3800004.zip
4-rw-r--r--.1rootroot1325Sep1115:3800005.zip
4-rw-r--r--.1rootroot1540Sep1115:4300010.zip
4-rw-r--r--.1rootroot1392Sep1115:4300011.zip
4-rw-r--r--.1rootroot1541Sep1115:4800016.zip
4-rw-r--r--.1rootroot1390Sep1115:4800017.zip
4-rw-r--r--.1rootroot2056Sep1115:45GAB_ZIP_INDEX.xml
3、unzip用法補充命令
將檔案解壓到當前目錄下
unziptest.zip
將檔案解壓到指定的目錄下,需要用到-d引數
unzip-d/temptest.zip
解壓後不覆蓋已經存在的檔案,使用-n引數;要以覆蓋方式解壓,使用-o引數
unzip-ntest.zip
unzip-n-d/temptest.zip
將壓縮檔案test.zip在指定目錄tmp下解壓縮,如果已有相同的檔案存在,用-o覆蓋原先的檔案
unzip-otest.zip-d/tmp/
只看一下zip壓縮包中包含哪些子檔案但不進行解壓,用-l引數
unzip-ltest.zip
檢視顯示的檔案列表還包含壓縮比率,用-v引數
unzip-vtest.zip
檢查zip檔案是否損壞,用-t引數
unzip-ttest.zip
以上就是關於扣丁學堂淺談Linux開發下如何利用unzip命令實現解壓多個檔案操作詳解的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值。