The until-do-done loop is like the while-do-done loop. The only difference is that it tests the condition and goes on executing as long as the condition remains false. It terminates execution as soon as the condition becomes true. The general syntax of this loop is:
until condition do command block done
The flow diagram of the until-do-done loop is shown in Figure 11-2.
As you may have noticed, the only difference between Figure 11-1 and Figure 11-2 is that the "True" and "False" positions have been interchanged. Here is script-22 , which has the same result as script-20 but was implemented using an until-do-done loop.
#!/usr/bin/sh echo "The until loop example" echo VAR1=1 until (( VAR1 > 100 )) do echo "Value of the variable is : $VAR1" ((VAR1 = VAR1 * 2)) done echo echo "The loop execution is finished"
Top |