469,620 Members | 1,857 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,620 developers. It's quick & easy.

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

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
1 2596
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.

Similar topics

43 posts views Thread by Gremlin | last post: by
19 posts views Thread by Dave | last post: by
19 posts views Thread by felixnielsen | last post: by
232 posts views Thread by robert maas, see http://tinyurl.com/uh3t | last post: by
26 posts views Thread by webrod | last post: by
9 posts views Thread by TF | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.