while ... do ... done ( en )

Last modification : 2013/01/26 19:17

The first loop syntax is the while loop.
while [ expr ]
do
      command
done

While the expr is true the command is executed.
msh> n=1 ; i=1
msh> while [ $i -le 10 ] ; do
    1> (( n = $n * $i ))
    1> (( i++ ))
    1> done
msh> print $n
3.6288e+006