Finding Files which Contain Specific Text

Command Line

At my current job, we are constantly looking for specific text within a folder of files because the code we need is all over the place.  Since I’m not a big command line guy (I’ll use it if I need to, but it typically requires a lot of google searches) I have been asking our server administrator to find files with specific text.  Finally I sat down with him and he explained how the following syntax helps me find files containing specific text.

find /staring/path -type f \( -iname \*.php -o -name \*.html \) -exec grep -Hn "search text" {} \;

For each find result, grep is executed and the -Hn (my contribution) returns the file name, the line number and displays the line syntax.

Thank you to all of the UNIX admins out there for all of your patience putting up with all of us GUI guys.