Recursive grep and filename wildcards

You can call grep with the -r switch to make it search recursively.

To search all files under /dir for "blah", run the following:

grep -r blah /dir

You can not use wildards directly in this manner, for example, the following will not search all text files:

grep -r blah *.txt

This doesn't work because the wildcard is expanded by the shell before grep is called. Instead, search the current directory (or whichever one you want) and pass the --include option:

grep -r blah . --include "*.txt"

References

Last modified: 03/06/08 16:44:27
Go to top

Related Pages

No related pages or links.

Login/out

Login

Forgot Password?
Go to top
Go to top