The while Loop – Linux Shell Programming

The while Loop – Linux Shell Programming

  • While loops repeat statements as long as the next Unix command is successful.

For Example :

#!/bin/sh
i=1
sum=0
while [ $i -le 100 ]; do
sum=`expr $sum + $i`
i=`expr $i + 1`
done
echo The sum is $sum.

 

while loop in linux shell program
while loop in linux shell program

 

 

 

For any query or issue, feel free to discuss on http://discuss.eduguru.in