Saturday, 29 November 2008

To search for a specific string in a specific file type across sub directories

Let's say I want to find the string "invalid" in files of type *.cp across subdirectories.

grep -r --include=*.cp "invalid" .

"-r" means look recursively

"." means look in this directory

You can also add other file types at the same time

grep -r --include=*.cp --include=*.h "invalid" .

No comments:

Post a Comment