1

When I want to find a file I use the command find <directory> -name <filename>. Often the command will output multiple lines with "Permission Denied" at the end. Is there a way to filter the results to exclude these lines?

gkeenley
  • 6,088
  • 8
  • 54
  • 129

1 Answers1

1

This will work

find <directory> -name <filename> 2>/dev/null

Example

[test@satellite ~]$ find / -name test
find: ‘/boot/grub2’: Permission denied
find: ‘/proc/tty/driver’: Permission denied
find: ‘/proc/1/task/1/fd’: Permission denied
find: ‘/proc/1/task/1/fdinfo’: Permission denied
find: ‘/proc/1/task/1/ns’: Permission denied

When 2>/dev/null is used

[test@satellite ~]$ find / -name test 2>/dev/null
/var/spool/mail/test
/usr/bin/test
/usr/lib64/python2.7/test
/usr/lib64/python2.7/site-packages/OpenSSL/test
/usr/lib64/python2.7/unittest/test
/usr/share/doc/jsr-305-0/sampleUses/test
Avinash Yadav
  • 781
  • 7
  • 13