Here's a fun way to do it with GNU Parallel, assuming that your find(1) doesn't support the -readable
flag:
find / -type f 2>/dev/null | parallel -m "grep blah {}"
The -m
option to parallel makes it stuff as many files as possible into each call to grep, which is more efficient that just grepping one file at a time.
I realize a problem with this is it will throw away other find
errors besides permissions problems. I suspect there may be a way to work around this with the find option -depth
but I haven't explored that yet.
It would be interesting to benchmark the find / grep
vs. grep -r
vs. parallel
approaches on a multicore system and see which is faster.