There are total 3 types of looping statements that can be used in bash programming  

  1. while statement
  2. for statement
  3. until statement

To control the flow of the loop, two control statements are used they are, 
 

  1. break
  2. continue

Their descriptions and syntax are as follows: 

while statement 

Here the command is evaluated and based on the resulting loop will be executed, if the command raises to false then the loop will be terminated 

for statement 

The for loop operates on lists of items. It repeats a set of commands for every item in a list. Here var is the name of a variable and word1 to wordN are sequences of characters separated by spaces (words). Each time the for loop executes, the value of the variable var is set to the next word in the list of words, word1 to wordN.

until statement 

 The until loop is executed as many times as the condition/command evaluates to false. The loop terminates when the condition/command becomes true. 

 

Leave a Reply