while loop in Shell Script
Syntax:
while [ condition ]
do
command1
command2
...................
...................
done
The while will execute as long as the given condition specified is true. For example : The for loop in last posted program we can be writte that using while loop as follows:
#vi naturalnumber.sh
i=0
while [ $i -le 9 ]
do
echo $i
i=`expr $i + 1`
done
Save it and try as
$ sh naturalnumber.sh
0 Comments:
Post a Comment