shell for loop 1

shell for loop

for i in {1..5}
do
   echo "Welcome $i times"
done

Here is what the above code is Doing:
1. The for loop is initialized with i = 1, and the condition is evaluated.
2. If the condition is true (1 is less than or equal to 5), the code within the loop is executed.
3. After the code within the loop has been executed, the condition is evaluated again.
4. If the condition is true, the code within the loop is executed again. This process repeats until the condition becomes false.
5. When the condition becomes false, the loop terminates.

Similar Posts