Each while loop consists of a set of commands and a condition. Posts: 7 Thanks Given: 0 . done Looping structures provided in Shell Scripts are while loop and for loop. I have started unixadminschool.com ( aka gurkulindia.com) in 2009 as my own personal reference blog, and later sometime i have realized that my leanings might be helpful for other unixadmins if I manage my knowledge-base in more user friendly format. do Let's break the script down. The inner while loop starts with a value of 1 and continues as long as the value is less than 5. var1=3 Inner loop: 3 / 4 = .7500, Bash Scripting – Redirecting Input in Scripts, Bash Scripting – using special variables related to parameters, Bash Scripting – Looping on File Contents, Linux Administration Interview Preparation [Free Email Crash Course], Roles and Responsibilities of System Admin [Free Course], Getting Started with RHEL7 Administration [Free Course]. Outer loop: 3 The bash shell knows when the first done command is executed that it … Inner loop: 3 / 3 = 1.0000 A nested loop is a loop within a loop, an inner loop within the body of an outer one. Of course, For example, run echo command 5 times or read text file line by line or evaluate the options passed on the command line for a script. And the result is today's' unixadminschool.com. Registered User. }, Published under the terms of the GNU General Public License. BoxAdcontent.document.close(); Nested loops are the loops inside a loop. while [ $var1 -ge 0 ] It is quite simple: a nested loop is an inner loop placed inside another one (loop). The CONSEQUENT-COMMANDS can be any program, script or shell construct. # placing a for loop inside a while loop A nested loop is a loop within a 1. Loops using while & for loop: Print nos. 1. The script is simple; it starts with the while command to check if the number is greater than zero, then the loop will run, and the number value will be decreased every time by 1, and on every loop iteration it will print the value of the number, Once the number value is zero the loop will exit. How this works is that the first pass of the outer loop triggers the inner loop, which executes to completion. There are 3 basic loop structures in Bash scripting which we'll look at below. BoxAdcontent.document.write("