Within a shell file the for structure without a specified list of values takes as its list of values the arguments specified on the command line when the shell was invoked. The syntax for "for" is as follows:
for variable
do
commands
done
The variable used in the for command is set automatically to each argument value in sequence. For example, if we had a file called "echofname" that contained this:
for fname
do
echo "$fname"
done
and we called it thusly:
$ echofname bob.txt frank.txt george.dat
we would get
bob.txt
frank.txt
george.dat
for - in
If in the for structure we specify a list of values, we can explicitly set the contents of the variable in the loop. For example, the following code
for grocery in milk cookies apples cheese
do
echo "Pick up $grocery"
done
would provide us with
Pick up milk
Pick up cookies
Pick up apples
Pick up cheese