Friday, September 5, 2014

Avoid error messages with `find` in *nix

Very useful comment on StackOverflow about how to get rid of error messages that come up when you use `find`.
You do not need sudo to run find for generally-accessible commands. If you don't want to see the error messages about inaccessible directories, get rid of the messages rather than using root privs unnecessarily. Using sudo all the time is a bad habit. Redirect stderr to /dev/null, like this:
find / -name java 2> /dev/null

Walter Underwood on SO