Searching inside a lot of files in Linux

Hi all,
how many times you Linux newbies needed to search inside a lot of files, looking for a specified string?

This task is really useful, specially when debugging websites and php scripts.

So, this is the command you need:


find . | xargs grep 'string to search'

Let’s look at how it works:

find – it returns the name of files found inside the given directory, recursively looking inside sub-directories, one name per line.

grep – it strips a line of a given input and returns it when result matches

xargs – executes a command, passing to it the arguments read from the standard input.

Bye!