I have a situation where I need to be able to run a script and delete specific files within a zip archive. Below is the general setup


Then within each zip file, there are a lot of files and directories. There could be 20+ directories deep so I need to make sure whatever I do recursively looks into the files.

I have played with the zipinfo -1 /mnt/directory/Folder1/file1.zip '.txt'* command it finds all .txt files in file1.zip, but I can't wildcard the zipinfo command to make it search all zip files. Also, I still need to be able to delete them after the fact. I have also tested zip -d /mnt/directory/Folder1/file1.zip filename.txt. This works fine for 1 file and 1 file only, as long as it's not within a folder. So again, not ideal for my situation.

I can unzip them if needed, but would prefer not as some are very large and I will have to zip them back anyway.


  • use find. find /mnt/directory -name "*.zip" and pipe it to unzip.
    – Brigo
    Apr 15, 2013 at 18:50
  • I've tried "find /mnt/directory -name ".zip" | zipinfo -1 ".doc" and it doesn't work because it's not reading the zip files.
    – Eric
    Apr 15, 2013 at 20:07
  • zipinfo do not accepts pipes. Try for i in $(find -iname ".zip"); do zipinfo $i;done
    – Brigo
    Apr 15, 2013 at 20:32
  • I got it workings with your recommendations above. This is my final output for the find command "find /mnt/directory/ -name "*.zip" -exec sh -c 'zipinfo -1 "{}" | grep -P "docx"' \;". Now my issue is I need to know what zip file the docx files come from. Currently it is just giving me the file names.
    – Eric
    Apr 16, 2013 at 14:26
  • From my approach, i has the name of the zip file, so adding a echo $i should be enought. You can try find mnt/directory/ -name "*.zip" -exec sh -c 'zipinfo -1 "{}" | grep -P "docx"; echo "filename: " "{}"'
    – Brigo
    Apr 16, 2013 at 14:53

1 Answer 1


The module Archive::Zip looks like it will do what you need.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .