In a script, the command following the done statement is executed. It is usually used when you need to manipulate the value of a variable repeatedly. A nested loop is a loop within a They say, while an expression is true, keep executing these lines of code. do How to print nos as 5,4,3,2,1 using while loop in using shell script? The same applies when you mix loop commands, such as placing a for loop inside a while loop: Again, the shell distinguished between the do and done commands of the inner for loop from the same commands in the outer while loop. Last updated: July 16, 2009. The CONSEQUENT-COMMANDS can be any program, script or shell construct. Do keep an eye on the brackets, for instance the conditional elements, (parenthesis brackets) for the condition and {braces} for the command block. BoxAdcontent.document.write("<\/head>"); Shell Scripting Tutorial by Steve Parker Buy this tutorial as a PDF for only $5. It is not part of the bash loop constructs. while [ $var1 -ge 0 ] Nested Loops. The bash while loop is a control flow statement that allows code or commands to be executed repeatedly based on a given condition. The other loops can be nested based on the programming requirement in a similar way − Nesting while Loops As a result, we have for and while loops in the Bourne shell. } A nested loop is a loop within a loop, an inner loop within the body of an outer one. This same process repeats until the condition becomes … echo “Outer loop: $var1” 9.2.2.1. Example 11-19. while [ $var2 -lt 5 ] Inner loop: 3 / 2 = 1.5000 Then the second pass of the outer loop triggers the inner loop again. Here’s a simple example of nesting a for loop inside another for loop: The nested loop (also called the inner loop) iterates through its values for each iteration of the outer loop. /* Join Date: Jun 2005. second pass of the outer loop triggers the inner loop BoxAdcontent.document.close(); Arithmetic in shell scripting: Performing real number calculation in shell script Converting decimal number to hexadecimal number Calculating factorial of given number File handling: Shell script to determine whether given file exist or not. They have the following format: while [ ] do done. #!/bin/bash BoxAdcontent.document.write("