How to perform Grep on many Gzip files, Searching for Specific information

Hello,

I am wondering if you can assist with my question and ask kindly for this.

I have a number of files that are listed as file1.gz through file100.gz.

I am trying to perform a grep on the files and find a specific date that only resides within within one of the files. There are multiple entries within the file so I am try to also limit the amount of output with the tail or head command.

My command is something like this, although it is incorrect:

gunzip -c file1.*.gz |grep -v "Jul 25 22:16:09" | tail -n 20

Thank you kindly.

You want the name of the file that has Jul 25 22:16:09 in it correct?

for filename in file*.gz
do
    gunzip $filename | grep -q 'Jul 25 22:16:09'
    if [[ $? -eq 0 ]] ; then
        echo $filename
        break
    fi
done

You might look at zgrep to simplify your answer (assuming it's available on your platform)

zgrep "Jul 25 22:16:09" file1.*.gz | tail -n 20

More info:

The Power of Z Commands - Zcat, Zless, Zgrep, Zdiff Examples (link removed)
zgrep(1) - Linux man page

Thanks much to those that responded.

Will try what was suggested and advise.

Best regards.