Filenames and linenumbers for the matches of cat and grep

Léo Léopold Hertz 준영 picture Léo Léopold Hertz 준영 · Feb 26, 2009 · Viewed 24.5k times · Source

My code

$  *.php | grep google

How can I print the filenames and linenumbers next to each match?

Answer

cadrian picture cadrian · Feb 26, 2009
grep google *.php

if you want to span many directories:

find . -name \*.php -print0 | xargs -0 grep -n -H google

(as explained in comments, -H is useful if xargs comes up with only one remaining file)