Skip to content

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.

Tell us what's on your mind

Discover more from Rob's Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading