O'Reilly logo

Solaris™ 8 Advanced System Administrator's Guide, Third Edition by Janice Winsor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Controlling the Flow

You can use loops to control the flow of execution in a script. A loop is an iterative mechanism that repeats a sequence of instructions until a predetermined condition is met. You can use different forms of loops. The for/foreach loop executes a list of commands one time for each value of a loop variable. The while loop repeatedly executes a group of commands within the body of the loop until the test condition in the expression is no longer true. The Bourne and Korn shells provide an until loop that continues to execute until a command executes successfully. Table 97 shows the syntax for for/foreach, while, and until loops.

Table 97. Looping Syntax
Feature Bourne/Korn Shell C Shell
for/foreach 
loops
for variable in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required