Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
2  
GNU find does not report such errors by default, at least not on my systems. –  grawity Aug 21 '11 at 10:36
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.