Every developer knows and loves GREP, the great search utility available on all Unix-based systems; while it does a great job searching, the options are a little lacking. One such option is restricting the search to only specific file types/extension. Luckily that functionality can be easily wrapped up in a handy script.
Create the script file:
sudo vim grepp
(You can name the script whatever you want, I named mine "grepp" for easier typing!)
Paste the following code:
grep $1 $(find . -name '\*.php' -or -name '\*.inc' -or -name '*.tpl')
(To search only .php, .inc and .tpl files.)
Save and quit:
Set the file permissions:
sudo chmod 0777 grepp
Run the script within any directory you'd like to search in:
grepp "foo bar"