I am using 'find' and 'grep' cygwin commands in order to locate files based on some pattern. I am doing this:

find . -iname '*.zip' -print -exec unzip -l {} \; 2> error.txt |grep -i vbs 

It works fine and I have file name with 'vbs' in file name. BUT now I need to do similar but I need to find the file name based on the content of it e.g. 'vbs' is not part of the file name but part of the file content. How it could be modified? Maybe something like :

find . -iname '*.zip' -print -exec unzip -l {} \; 2> error.txt | xargs ??? Could someone advice? Thanks

1 Answer 1


Since you are going to grep the file content, -l listing the zip file won't be enough. you need to actually unzip it. so:

temp=`mktemp -d`    
find . -iname '*.zip' -print -exec unzip -d $temp {} \; 2> error.txt
grep -ir vbs $temp   
  • Well ... It doesn't work that way, I've got this error: grep: unknown option -- ------- Usage: grep [OPTION]... PATTERN [FILE]... Try 'grep --help' for more information. grep: unknown option -- -------
    – susik
    Commented Jun 22, 2016 at 14:20

You must log in to answer this question.

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