(Note: Both of these examples may require GNU or BSD
find and may not work as-is with the POSIX "edition" of
Both of the scriptlets below must be understood as excerpts from way more complex scripts, with the gist having been compacted into a few lines.
As I get the exact same results with both variants, I'm wondering where the differences (respectively: pitfalls) of either implementation may be...
- var. 1
while IFS= read -r f; do echo "reading entry: "$f"" done < <(find ~/workdocs -type f -name '*.pdf' -print)
- var. 2
while IFS= read -rd '' f; do echo "reading entry: "$f"" done < <(find ~/workdocs -type f -name '*.pdf' -print0)
It turned out that the output (which this question is all about here) was entirely identical in both cases. (Tested by redirecting to output log file, then
Still, I am wondering if there might be any borderline cases which may actually cause the outputs from variant #1 and #2 to differ.
This is what I'd like to know about.