Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a setup where I need to use 'find' to find 0 or more files in a certain directory, however, 'find' always produces an error when there are no files that match a certain check. Is it possible to run 'find' while having it omit errors when no files match the pattern?

share|improve this question
GNU find does not report such errors by default, at least not on my systems. – grawity Aug 21 '11 at 10:36
up vote 1 down vote accepted

Like @grawity said find isn't expected to report these errors. Anyway if you want to suppress error output redirect stderr to /dev/null:

find  . HERE_YOUR_FIND_PARAMS 2&> /dev/null

One typical case in which find write to stderr happens when there is a directory in your find searching sub-path that hasn't the permission to be opened.

share|improve this answer
Thanks, this works as I needed it to. – Eli Aug 21 '11 at 19:39
Why do use 2&> instead of 2>? – Frank Meulenaar Dec 16 '14 at 9:06

Can you just ignore the errors? Or, more specifically, redirect them to /dev/null?

share|improve this answer
I'm using the results in a script, so no, I can't just ignore the errors. Redirecting stderr to /dev/null works, however. – Eli Aug 21 '11 at 19:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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