Linux下使用unzip命令解压多个文件

Linux下直接使用unzip *.zip解压多个文件会报错
可以使用unzip '*.zip'或者 unzip "*.zip"或者unzip \*.zip命令
或者使用for z in *.zip; do unzip $z; done执行解压

  1. 如下可以看到当前目录下有6个zip压缩包文件
[root@autoServer COLLECTION]# ll -s
total 24
4 -rw-r--r--. 1 root root 1681 Sep 11 15:38 00004.zip
4 -rw-r--r--. 1 root root 1325 Sep 11 15:38 00005.zip
4 -rw-r--r--. 1 root root 1540 Sep 11 15:43 00010.zip
4 -rw-r--r--. 1 root root 1392 Sep 11 15:43 00011.zip
4 -rw-r--r--. 1 root root 1541 Sep 11 15:48 00016.zip
4 -rw-r--r--. 1 root root 1390 Sep 11 15:48 00017.zip
  1. 使用unzip \*.zip命令进行解压,可以看到6个文件都解压成功了
[root@autoServer COLLECTION]# unzip \*.zip
Archive:  00005.zip
  inflating: GAB_ZIP_INDEX.xml       
  inflating: 15366516000003-BASIC_1004.bcp  

Archive:  00010.zip
replace GAB_ZIP_INDEX.xml? [y]es, [n]o, [A]ll, [N]one, [r]ename: n     
  inflating: 15366518460006-SOURCE_1001.bcp  

Archive:  00016.zip
replace GAB_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  

6 archives were successfully processed.
  1. 再查看当前目录已经有了解压后的文件
[root@autoServer COLLECTION]# ll -s
total 52
4 -rw-r--r--. 1 root root  294 Sep 11 15:40 15366516000001-BASIC_1003.bcp
4 -rw-r--r--. 1 root root  158 Sep 11 15:40 15366516000003-BASIC_1004.bcp
4 -rw-r--r--. 1 root root  104 Sep 11 15:45 15366518460006-SOURCE_1001.bcp
4 -rw-r--r--. 1 root root   80 Sep 11 15:45 15366518480008-SOURCE_1002.bcp
4 -rw-r--r--. 1 root root  104 Sep 11 15:50 15366519060012-SOURCE_1001.bcp
4 -rw-r--r--. 1 root root   80 Sep 11 15:50 15366519080014-SOURCE_1002.bcp
4 -rw-r--r--. 1 root root 1681 Sep 11 15:38 00004.zip
4 -rw-r--r--. 1 root root 1325 Sep 11 15:38 00005.zip
4 -rw-r--r--. 1 root root 1540 Sep 11 15:43 00010.zip
4 -rw-r--r--. 1 root root 1392 Sep 11 15:43 00011.zip
4 -rw-r--r--. 1 root root 1541 Sep 11 15:48 00016.zip
4 -rw-r--r--. 1 root root 1390 Sep 11 15:48 00017.zip
4 -rw-r--r--. 1 root root 2056 Sep 11 15:45 GAB_ZIP_INDEX.xml

unzip用法补充命令

  • 将文件解压到当前目录下
unzip test.zip
  • 将文件解压到指定的目录下,需要用到-d参数
unzip -d /temp test.zip
  • 解压后不覆盖已经存在的文件,使用-n参数;要以覆盖方式解压,使用-o参数
unzip -n test.zip
unzip -n -d /temp test.zip      
  • 将压缩文件test.zip在指定目录tmp下解压缩,如果已有相同的文件存在,用-o覆盖原先的文件
unzip -o test.zip -d /tmp/
  • 只看一下zip压缩包中包含哪些子文件但不进行解压,用-l参数
unzip -l test.zip
  • 查看显示的文件列表还包含压缩比率,用-v参数
unzip -v test.zip
  • 检查zip文件是否损坏,用-t参数
unzip -t test.zip

参考博文
https://blog.csdn.net/jaye16/article/details/74978408
https://blog.csdn.net/qq_35399846/article/details/70168002

    原文作者:Yvanna_15
    原文地址: https://www.jianshu.com/p/3570c459eabe
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞