The while loop executes the commands between the do and done statements as long as the tested condition is true. Here is the syntax:
Here is a simple example:
while [ $NUM -lt 5 ]
echo “The number is “$NUM”.”
let NUM=$NUM+1 # let is a Bash and Korn shell built-in command for math.
In the example above you can see that the while loop executes while the value of the NUM variable is less than 5: