3 ms·
Also, IIRC, and less commonly seen, you can do: for i do # your commands using $i here done which will iterate over all the command line argument
by fuzztester 3y ago
Also, IIRC, and less commonly seen, you can do:
for i
do
# your commands using $i here
done
which will iterate over all the command line arguments to the script containing that for loop.
It is a shortcut for:
for i in $*
# note: not for i in *
# the rest is the same above
This is mentioned in either the shell man page or in the Kernighan & Pike book The Unix Programming Environment.