recursively grep files

From Gary Utz, just a one liner to recursively grep on any machine equipped with find, xargs and grep. I use it to search through Apache conf files.

Here’s the quintessential example:

find . -name "*.conf" | xargs grep 'string you're looking for'

Note that it’s always best to narrow your search by specifying a file name, part file name or extension. In the example I’ve specified files with the “.conf” extension. I could just as easily used “*.php” or “*.*”, the latter being the “greediest” and bound to take the longest depending upon how many files you have to go through.

You can also bound the search in time by using the “-mtime” option (see this post for more on that).