Find and grep permission denied messages on Linux

Trying to run find command on Linux

find /dir1 -name "*.bak" -print

Getting Permission denied messages:

find: ‘/dir1/lobby.conf’: Permission denied
find: ‘/dir1/images’: Permission denied
find: ‘/dir1/nginx.conf’: Permission denied

Is there is a way to find and grep permission. I just need to hide Permission denied messages but show all other errors on screen.

Never mind, I found solution. It was pretty simple:

### find grep permission denied ### 
find /dir1 -name "*.bak" -print  2>&1 | grep -v "Permission denied"
find /dir1 -name "*.bak" -print  2>&1 | grep -v "Permission denied" > list.txt
vi list.txt
more list.txt

Source


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki