4 ms·
They work 100 % of the time if you do it right. An example: find . -type f -name foo -print0 | while read -rd ''; do grep -l bar "${REPLY}" done
by unhammer 13y ago
They work 100 % of the time if you do it right. An example:
find . -type f -name foo -print0 | while read -rd ''; do
grep -l bar "${REPLY}"
done
find separates its output with the NUL byte when you do -print0, and -d '' means read NUL-separated input.
Of course, in this case it would be better to use:
find . -type f -name foo -print0 | xargs -0 -I{} grep -l bar '{}'
but if you've got several things to do for each file, the first one makes sense (or you can put those several things in a script, and use xargs).