By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,799 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,799 IT Pros & Developers. It's quick & easy.

the following code goes into infinite loop and does not increment variable i

P: 26
the code is as

#!/bin/sh

i=1;
while [ $i -le 5 ]
do
echo "welcome $i times";
i= 'expr $i + 1 ';
done


the give code goes into infinite loop and doesnot increment the variable i



exit 0;
Dec 24 '07 #1
Share this Question
Share on Google+
1 Reply


P: 3
hey the code is OK

just put `` instead of '' for expr

i=`expr $i + 1`

after changing the script will give you exact output
welcome 1 times
welcome 2 times
welcome 3 times
welcome 4 times
welcome 5 times
Dec 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.