how do you search for a particular keyword within a php file?

Go To


I'm trying to search for a word/phrase within all the php files and all sub-directories where the command is run from. I'm using ssh with root access.

2012-04-04 21:23
by user962449


find . -type f -name \*php|xargs grep -i yourword
2012-04-04 21:24
by Marc B
I just want a list of all the php files that contain the keyword and not the contents inside. Is that possible - user962449 2012-04-04 21:29
The "-c" flag will work, e.g. "grep -ic yourword - coder_tim 2012-04-04 21:31
that's perfect, but how can it now only show the results where the keyword was actually found - user962449 2012-04-04 21:33
-n option will print the line numbers of where the matches were found - Marc B 2012-04-04 21:37
thanks, found that -l helps too - user962449 2012-04-04 21:41