Im using the following to serch for a string in all the files in a directory.

grep -Flr --include "*" 'mystring' /modules/

Which works perectly fine and returns the files which contain the string. However I also get a list of files with permission denied next to them which means looking for the results a bit harder.

Is there a flag to pass to the command to ignore outputting permission denied errors.

Thanks

link|improve this question
feedback

migrated from stackoverflow.com Jan 8 '10 at 13:59

This question came from our site for professional and enthusiast programmers.

1 Answer

I usually just use:

grep -Flr --include "*" 'mystring' /modules/ 2>/dev/null

which will throw away all output to standard error.

If (as you seem to indicate in your comment), your version of grep outputs its errors to sandard output, you can filter that output with something like:

grep -Flr --include "*" 'mystring' /modules/ | egrep -v 'Permission denied|ERROR'

which will throw away lines based on whatever pattern you deem is necessary.

link|improve this answer
Thanks however for me it didn't work. I found the following to work: grep -Flr --include "*" 'mystring' /modules/ | grep -v Perm – shambl3 Sep 18 '09 at 11:09
feedback

Your Answer

 
or
required, but never shown