User Tools

Site Tools


bash:while_loop

This is an old revision of the document!


BASH - While loo

The while loop construct is used for running some instruction multiple times.

#!/bin/bash
i=0
 
while [ $i -le 2 ]
do
echo Number: $i
((i++))
done

So, the while loop takes the below form.

while [ condition ]
do
commands 1
commands n
done

NOTE: The space surrounding the square brackets are mandatory.

bash/while_loop.1594805433.txt.gz · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki