8.6.19 Script snippets for looping over each file
The following ways of looping over each file matching
*.ext ensures proper handling of funny file names such
as ones with spaces and performs equivalent process:
-
Shell loop (This example is multi line style with PS2="
" . To do the same in one line, you insert a semicolon for each
line break.):
for x in *.ext; do
if test -f "$x"; then
command "$x"
fi
done