Often, I search for a function, most likely a wordpress function, within the PHP files. It is usually done within wordpress themes that contains a few other files too, particularly minified CSS file that results in seeing the entire minified CSS file in the output of the search result. This is pretty annoying to say the least.
Now, I started using an alias that finds only the PHP files and then pass the result to a grep command to find only what I really need. Here’s the alias…
alias findinphp='find * -type f -name '*.php' -print0 | xargs -0 grep -inr'
I could have used the built-in -exec option too. However, it doesn’t play well when we search thousands of files. Moreover, using xargs is safe and faster.