Reputation: 3
# !/bin/sh
i=1
while [ $i -lt 10 ]
do
echo $i
i= 'expr $i + 1'
done
example program to display the numbers from 1 to 9..but it is entering into infinite loop while executing..
Upvotes: 0
Views: 63
Reputation: 832
replace the line
i= 'expr $i + 1'
with
i=`expr $i + 1`
u used (') symbol but it is 'back quote symbol'(above tab button)and dont give space between '=' and '`' click here for code
Upvotes: 0
Reputation: 2030
Your incrementation is causing the problem. Try this:
# !/bin/sh
i=1
while [ $i -lt 10 ]
do
echo $i
i=$(( i+1 ))
done
Upvotes: 1