You can just do forfin * (or other shell glob), unless you need find’s fancy search/filtering features.
The shell glob isn’t just simpler, but also more robust, because it works also when the filename contains a newline; find .. | whileread -r will crap out on that. Also apparently you want while IFS= read -r because otherwise read might trim whitespace.
If you want to avoid that problem with the newline and still use find, you can use find -exec or find -print0 .. | xargs -0, or find -print0 .. | while IFS= read -r -d ''. I think -print0 is not standard POSIX though.
You can just do
for f in *
(or other shell glob), unless you needfind
’s fancy search/filtering features.The shell glob isn’t just simpler, but also more robust, because it works also when the filename contains a newline;
find .. | while read -r
will crap out on that. Also apparently you wantwhile IFS= read -r
because otherwise read might trim whitespace.If you want to avoid that problem with the newline and still use find, you can use
find -exec
orfind -print0 .. | xargs -0
, orfind -print0 .. | while IFS= read -r -d ''
. I think-print0
is not standard POSIX though.Doesn’t that depend on the shell?
I don’t think so and have never heard that, but I could be wrong.