I'm trying to filter out the lines, that contain the Permission denied from the find command.
If I'm running:
find ~ -name "fifo" | grep "Permission denied"
The output is correct:
find: ‘/home/nroby/.cache/dconf’: Permission denied
find: ‘/home/nroby/.dbus’: Permission denied
find: ‘/home/nroby/.config/enchant’: Permission denied
However if I'm using the -v option: find ~ -name "fifo" | grep -v "Permission denied"
The output is:
find: ‘/home/nroby/.cache/dconf’: Permission denied
find: ‘/home/nroby/.dbus’: Permission denied
/home/nroby/Desktop/Linux/fifo
find: ‘/home/nroby/.config/enchant’: Permission denied
The lines saying Permission denied come from stderr, not stdout. The terminal displays both streams, but the pipe redirects only stdout (so with your command, grep never sees a line containing Permission denied).
So, if you only want to silence these messages, do this instead:
find ~ -name "fifo" 2>/dev/null
2> redirects stderr.
If you need to pipe both stdout and stderr for some reason (e.g., you want other error messages present in your output), you can do this:
find ~ -name "fifo" 2>&1 | grep -v "Permission denied"
2>&1 redirects stderr to stdout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With