you can filter out messages to stderr. I prefer to redirect them to stdout like this.
#find / -name art 2>&1 | grep -v “Permission denied”
In short, all regular output goes to standard output (stdout). All error messages to standard error (stderr).
grep usually finds/prints the specified string, the -v inverts this, so it finds/prints every string that doesn’t contain “Permission denied”. All of your output from the find command, including error messages usually sent to stderr (file descriptor 2) go now to stdout(file descriptor 1) and then get filtered by the grep command.
#find -type f ./ | xargs grep shit
“-type f ” will also forbid showing the searching target is directory.
if you want grep something, following will be pretty useful,
For BSD or GNU grep you can use
-B num to set how many lines before the match and
-A numfor the number of lines after the match.
grep -B 3 -A 2 foo README.txt
If you want the same number of lines before and after you can use
grep -C 3 foo README.txt
This will show 3 lines before and 3 lines after.
find / | xargs grep aoa 2>&1 | grep -v “Permission denied”