Correct Way To Iterate Over Files In Bash

Because I keep forgetting, here’s a reminder to myself of the correct way to iterate through files and directories in bash, even considering spaces in filenames, whith a hat-tip to Thomas Howard Uphill:

find . -type f|grep .ext$ |while read file
do
/do/something/to "$file"
done

Silly rabbit.

2 Replies to “Correct Way To Iterate Over Files In Bash”

Tell us what's on your mind