Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

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.

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.