I started using sed
recently. One handy way I use it is to ignore unimportant lines of a log file:
tail -f example.com-access.log | sed '/127.0.0.1/d;/ELB-/d;/408 0 "-" "-"/d;'
But when I try to use it similarly with find
, the results aren't as expected. I am trying to ignore any line that contains "Permission denied" like this:
find . -name "openssl" | sed '/Permission denied/d;'
However, I still get a whole bunch of "Permission denied" messages in stdout
.
EDIT
As mentioned in the correct answer below, the "Permission denied" messages are appearing in stderr
and NOT stdout
.
grep
/egrep
. – Michael Hampton Jul 10 '13 at 02:13grep
would help me out here. – Jul 10 '13 at 02:14find
. I can't write a regex that matches results that are unknown. – Jul 10 '13 at 02:22-v
) – Andrew B Jul 10 '13 at 02:53grep -v 'Permission denied'
,grep -Ev '(Permission denied|kitchen sink)'
, etc. – Andrew B Jul 10 '13 at 03:42find
command through thatgrep
command, as in:find . -name "openssl" | grep -v "Permission denied"
. That doesn't work. – Jul 10 '13 at 04:16grep
to do the same thing, as I believe that is what you are telling me is possible. – Jul 10 '13 at 04:27find . -name "openssl" 2>&1 | grep -v "Permission denied"
– Andrew B Jul 10 '13 at 04:35