Showing posts with label shell programs using different types of loops.. Show all posts
Showing posts with label shell programs using different types of loops.. Show all posts

Saturday, March 21, 2015

shell programs using different types of loops.

Shell supports a set of loops such as for, while and until to execute a set of statements repeatedly. The body of the loop is contained between do and done statement. The for loop doesn't test a condition, but uses a list instead.
for variable in list
do
statements
done

The while loop executes the statements as long as the condition remains true.
while [ condition ]
do
statements
done

The until loop complements the while construct in the sense that the statements are executed as long as the condition remains false.
until [ condition ]
do
statements
done