Now we're all familiar with not using:
find . -print | xargs cmd
but using
find . -print0 | xargs -0 cmd
To cope with filenames containing e.g. newline, but what about a line I have in a script:
find $@ -type f -print | while read filename
Well, I assumed it would be something like:
find $@ -type f -print0 | while read -d"\0" filename
And if I'd simply done:
find $@ -type f -print0 | while read filename
I'd be seeing the NULLs?
But No, the while loop exits after zero times around (in both cases) I assume because the read returned zero, also I assume because it read a NULL (\0) .
Feels like the bash read should sport a "-0" option.
Have I misread what's happening or is there a different way to frame this?
For this example I may well have to recode to use xargs but that's a whole heap of new processes I didn't want to fork.