unzip解压当前目录下多个zip文件到指定目录

目的:解压PicFile下的所有zip文件到PicFiles下

[root@cmdiFile PicFiles]# unzip -d /mnt2/shanxi/PicFiles /mnt2/shanxi/PicFile/*.zip  
Archive:  /mnt2/shanxi/PicFile/P-WX-20170808-00005.zip
caution: filename not matched:  /mnt2/shanxi/PicFile/P-WX-20170808-00006.zip
caution: filename not matched:  /mnt2/shanxi/PicFile/P-WX-20170808-00007.zip
caution: filename not matched:  /mnt2/shanxi/PicFile/P-WX-20170808-00008.zip
caution: filename not matched:  /mnt2/shanxi/PicFile/P-WX-20170808-00009.zip
caution: filename not matched:  /mnt2/shanxi/PicFile/P-WX-20170808-00010.zip
caution: filename not matched:  /mnt2/shanxi/PicFile/P-WX-20170808-00011.zip
caution: filename not matched:  /mnt2/shanxi/PicFile/P-WX-20170808-00012.zip

使用 unzip -d /mnt2/shanxi/PicFiles /mnt2/shanxi/PicFile/*.zip命令报错,然后尝试写脚本执行

#!/bin/bash
#解压文件
#
for i in `ls /mnt2/shanxi/PicFile/`
do
unzip $i -d /mnt2/shanxi/PicFiles/
done

报以下错误:

unzip:  cannot find or open P-WX-20170808-00005.zip, P-WX-20170808-00005.zip.zip or P-WX-20170808-00005.zip.ZIP.
unzip:  cannot find or open P-WX-20170808-00006.zip, P-WX-20170808-00006.zip.zip or P-WX-20170808-00006.zip.ZIP.
unzip:  cannot find or open P-WX-20170808-00007.zip, P-WX-20170808-00007.zip.zip or P-WX-20170808-00007.zip.ZIP.
unzip:  cannot find or open P-WX-20170808-00008.zip, P-WX-20170808-00008.zip.zip or P-WX-20170808-00008.zip.ZIP.
unzip:  cannot find or open P-WX-20170808-00009.zip, P-WX-20170808-00009.zip.zip or P-WX-20170808-00009.zip.ZIP.

后来将命令改为: unzip -d /mnt2/shanxi/PicFiles '/mnt2/shanxi/PicFile/*.zip',执行成功,原因是系统将多个zip文件认为是在一个文件中,所以会报错。

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值