2 views

There are scenarios where we need to get the matching lines alone ignoring all error messages such as "permission denied" from the find command output.

Solution:

find /PATH -name KEYWORD 2>/dev/null

The 2>/dev/null at the end will redirect all ERROR messages to /dev/null (/dev/null is a device file that discards all data written to it)

Example: find output cleaned up ignoring error messages

[developer@askdevops/]$ find /var -name messages 2>/dev/null
/var/log/messages

Example: find command without error redirection

[developer@askdevops/]$ find /var -name messages
find: ‘/var/lib/machines’: Permission denied
find: ‘/var/lib/polkit-1’: Permission denied
find: ‘/var/lib/rpcbind’: Permission denied
find: ‘/var/log/audit’: Permission denied
/var/log/messages
find: ‘/var/log/httpd’: Permission denied
find: ‘/var/log/mariadb’: Permission denied
Sep 24, 2015 by | 2 views
Articles for DevOps Geeks
MobaXterm Customization
CHMOD Explained!
Bash history powerful tips
Ubuntu bash from Windows
..