September 13, 2017

How many times have you executed find only to see copious error messages that drown out the meaningful output? Sure, you could redirect stderr to /dev/null but then you might miss an actual error. There is a solution.

By adding an alias to your .bashrc you can filter out errors for non-readable files.

f()
{
    local start="$1"
    shift
    find $start ! -readable -prune -o $* -print
}

In English this alias uses the first argument as the search directory. It then removes all non-readable results. Finally all remaining arguments are passed to find. The downside to this alias is that -print is specified. If you don’t want that flag you are out of luck and should use find directly.

References

Stackoverflow

comments powered by Disqus