That's nothing to do with grep
- it's because the pipe |
redirects the standard output stream stdout
whereas the Permission denied
messages are in the standard error stream stderr
. You could achieve the result you want by combining the streams using 2>&1
(redirect the stream whose file descriptor is 2
to the stream whose file descriptor is 1
) so that stderr
as well as stdout
gets piped to the input of the grep command
find / -name libGL.so.1 2>&1 | grep -v 'denied'
but it would be more usual to simply discard stderr
altogether by redirecting it to /dev/null
find / -name libGL.so.1 2>/dev/null
Using |& instead of 2>&1 |
If you take a look at the Bash man page you'll likely notice this blurb:
If |&
is used, the standard error of command is connected to command2's standard input through the pipe; it is shorthand for 2>&1 |
.
So you can also use this construct as well if you want to join STDERR and STDOUT:
find / -name libGL.so.1 |& grep -v 'denied'