Your issue is that you're trying to filter out (remove) the error messages from the standard output of
find. Error messages (and general diagnostic messages, as well as interactive prompts) are displayed on the standard error stream, which can't be piped. You therefore can't get rid of the error messages using
grep (without merging the standard error stream into the standard output stream).
find (which implements the nonstandard
find . -type d ! -readable -prune -o -name xyz -print
This would look for anything called
xyz in or below the current directory and print out the found pathnames. Whenever
find encounters a directory that the current user does not have access to read, this directory is removed from the search tree (the search tree is pruned with
This gets rid of the "permission denied" errors originating from trying to access directories that you can't access. It does this by simply not getting into situations where these errors would be generated.
grep, this will also avoid accidentally filtering out files found in directories called, literally,
Permission. It also allows you to see any other errors that may be generated while searching for
xyz (whatever these errors might be), or to write in-line scripts, executed through
find ... -exec ... that may want to use the error stream, or to use
find ... -ok ... for asking the user for confirmation before performing some action.