422 Introduction to Computational Modeling
for variable [in argument list]
do
command block
done
The following example shows a short script file with a for loop.
# File: loopex1. Example of for-loop
# for system in Linux Windows Solaris OS2 MacOSX
do
echo $system
done
The execution of the script file is shown in the following listing:
./loopex1
Linux
Windows
Solaris
OS2
MacOSX
The while loop allows repeated execution of a block of commands based on a
condition of an expression. The general syntax of the while command follows.
while expression
do
command-block
done
The expression in the while command is evaluated and if true, the command
block is executed and the expression is again evaluated. The sequence is repeated
until the expression evaluates to false. The following ...