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:

text_to_search
the actual text to search for

-R
Recurse to subdirectories

.
start from the current directory

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

?color
makes the output pretty

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

Leave a Reply

You must be logged in to post a comment.