Possible Duplicate:
How do I remove “permission denied” printout statements from the find program?

When I run this command in Linux (SuSE):

find / -name ant

I get many error messages of the form:

find: `/etc/cups/ssl': Permission denied

Does find take an argument to skip showing these errors and only try files that I have permission to access?

marked as duplicate by Gilles, George M, Mat, Michael Mrozek Jul 13 '12 at 20:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Since you ask about an argument to find, please consider: find / ! -readable -prune. This is like "prune those results not (!) readable". See: stackoverflow.com/questions/762348/… – appas Sep 16 '16 at 11:21
up vote 71 down vote accepted

you can filter out messages to stderr. I prefer to redirect them to stdout like this.

 find / -name art  2>&1 | grep -v "Permission denied"


In short, all regular output goes to standard output (stdout). All error messages to standard error (stderr).

grep usually finds/prints the specified string, the -v inverts this, so it finds/prints every string that doesn't contain "Permission denied". All of your output from the find command, including error messages usually sent to stderr (file descriptor 2) go now to stdout(file descriptor 1) and then get filtered by the grep command.

This assumes you are using the bash/sh shell.

Under tcsh/csh you would use

 find / -name art |& grep ....
  • 24
    or even just find / -name art 2>/dev/null – rush Jul 11 '12 at 20:06
  • 8
    @rush That would filter out all error messages, not just the permission denied ones – Michael Mrozek Jul 11 '12 at 23:08
  • Think about it, that's about all find CAN return as an error message. Disk full, disk read error, ... possible, but rare, and find isn't geared to handle those. You've got OTHER issues if those errors show up anyways. Find's own error result is even vague.. 0=good, !0=something happened. Not even really differentiating anything but pass/fail. – lornix Jul 13 '12 at 3:24
  • I'm with @MichaelMrozek on this, I would rather see all possible error messages and then decide to filter them out instead of sending them to the bit-bucket unseen. – Levon Jul 13 '12 at 3:35
  • When I use find 2>/dev/null I always want only the result set not any other error messages. When a result set returned with null I just run the "regular" find and figure out what the problem is. – Bálint Babics Jun 28 at 14:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.