简体   繁体   English

存在其他文件时,如何在Linux中解压缩文件

[英]How can I unzip files in Linux when other files are present

I have files such as these 我有这样的文件

a1.tif
a2.tif
a1.zip
sa.zip
ff.zip
wqqq.zip
  1. I want to unzip only the zip files and ignore the .tif files 我要解压缩压缩文件,而忽略的.tif文件
  2. Also ignore those .zip files that have already been decompressed. 也忽略那些已经解压缩的.zip文件。

I am getting this 我得到这个

 unzip /*zip
unzip:  cannot find or open /*zip, /*zip.zip or /*zip.ZIP.

You are searching for anything in the root directory that ends with "zip". 您正在根目录中搜索以“ zip”结尾的任何内容。 Use *.zip for any file in the current directory ending in ".zip", or more explicitly use ./*.zip , ./ being the current directory. 使用*.zip的任何文件在“.ZIP”结束当前目录,或者更明确地使用./*.zip./是当前目录。

That said, if you have more than one match it will pass all of them to the unzip command with the first being interpreted as the archive file and the remaining matches as files to extract from the archive. 就是说,如果您有多个匹配项,它将把所有匹配项都传递给unzip命令,第一个被解释为存档文件,其余匹配项作为要从存档中提取的文件。 Avoid this by using find to pass each match to unzip . 通过使用find将每个匹配项传递给unzip来避免这种情况。

find . -name '*.zip' -exec unzip {} \;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM