简体   繁体   中英

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
  2. Also ignore those .zip files that have already been decompressed.

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". Use *.zip for any file in the current directory ending in ".zip", or more explicitly use ./*.zip , ./ being the current directory.

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. Avoid this by using find to pass each match to unzip .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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