Grep a pattern from zip file which has multiple files insdie

Hi Gurus,

I got a small requirement in my script to grep a specific pattern in a zip compressed file which has been created with multiple files.

Sample File: 20180913.zip

$> zipinfo -l 20180913.zip
20180913_file1
20180913_file2
20180913_file3
20180912_file4
20180912_file5
20180911_file6
20180911_file7
$>

I need to grep a country Mexico in all these files in the zip and print the content. Can someone provide any relevant article or exact way to accomplish it please?

Thanks in Advance.
Venkat

If the archive isn't compressed, just using:

grep Mexico archive

might give you the lines you want in all of the files in the archive.

If the archive is compressed or if you need to know which files in the archive contain matching lines, the typical way to do so it to create a new directory, unzip the files in the archive into that directory, move into that directory, and then run:

grep Mexico *

Some versions of zip/unzip may have options to do what you want without unzip ing the archive. Since you haven't given us any indication of what operating system you're using, we can't make any guess at whether or not your implementation might have such an option.