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?

2

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.