Thursday, May 16, 2013

Grep and recursion

Grep has for a long time had a recursive option "-r" but I have never been able to get it to do what I want because if you write
$ grep -r test *.txt
The *.txt part specifies the files to look in, and since the folders I want to recurse don't end with .txt it doesn't recurse into them.
The correct way to cause grep to recurse is to specify file patterns separately.
$ grep -r test --include "*.txt" ./

No comments:

Post a Comment