zgrep multiple gz files in directory

bash, grep

Solution

You could supply the `-H` option to list the filename:

find /var/www/page/logs/ -name "*.gz" -exec zgrep -H '/index.php' {} \;

If you wanted only the list of matching files, use `-l`:

find /var/www/page/logs/ -name "*.gz" -exec zgrep -l '/index.php' {} \;

Problem

I have problem executing `zgrep` command for looking for `word` in the directory where I have almost 1000 `*.gz` files. I am trying with: ``` find /var/www/page/logs/ -name "*.gz" -exec zgrep '/index.php' {} \; ``` result is: ``` GET : '/index.php' GET : '/index.php' GET : '/index.php' ``` And it works.I get list of occurance of `index.php` with no file name where it was found. It is kind of useless for me unless i knew in which files (filename) it appears. How can i fix it?

Original source