Using grep to search for a text within files recursively

Thursday, 14. June 2012

To search for text in files from the current folder recursively. you can :

grep text_to_search -R . -n --include=*.php --color

The parameters are as follows:

the actual text to search for

Recurse to subdirectories

start from the current directory

specifies a regular expression that searchable files must match (in my case, search only files with the ‘php’ extension)

makes the output pretty

shows the lines numbers of the lines that matched your search text

Leave a Reply

You must be logged in to post a comment.