When using the find
command from ~
or /
, it is common to get errors related to access rights (Permission denied
or Operation not permitted
).
Running the find
command with sudo
removes some of these errors, but not all, and anyway running the command with elevated privileges is not an option.
So the question is: does the find
command have a flag similar to the grep
silent mode flag (grep -s
) that would prevent these errors?
Edit:
The solution of removing all errors suggested several times on this page is not very elegant and potentially dangerous (find / 2>/dev/null
).
A good solution comes from this answer https://unix.stackexchange.com/a/42842/199660. For example:
find / -type f -iname "*balance*.pdf" 2>&1 | grep -v 'Operation not permitted' | grep -v 'Permission denied' | grep -v 'No such file or directory' | grep -v 'Not a directory'
Still, it would be nice that find
provides a flag for this purpose.