1827980 Members
2286 Online
109973 Solutions
New Discussion

Script for adding

 
SOLVED
Go to solution
Henry Chua
Super Advisor

Script for adding

Hi guys,

I have tried out this in my shell script, doesnt seem to be correct though.. any suggestion?

while(TRUE)
y=0
x=`awk '{ print $5 }' $BUF`
let y=y+x
done

it gave an error "y=y+: more tokens expected"

May I know how this can be corrected?

5 REPLIES 5
Ravi_8
Honored Contributor

Re: Script for adding

while(TRUE)
y=0
x=`awk '{ print $5 }' $BUF`
y=y+x
done
never give up
Henry Chua
Super Advisor

Re: Script for adding

Hi Ravi

y=0
while(TRUE)
x=`awk '{ print $5 }' $BUF`
y=y+x
done

using the script..
when i echo "$y" i got "y+88" ....
Biswajit Tripathy
Honored Contributor
Solution

Re: Script for adding

Try:

integer y=0
while(TRUE)
x=`awk '{ print $5 }' $BUF`
y=$y+$x
done

- Biswajit
:-)
Alexander M. Ermes
Honored Contributor

Re: Script for adding

Hi there.
Here an idea :

export NC0="0"
export NC1="0"
export NC2="0"
export NC3="0"

NC0=`expr $NC0 + 1`
#
#
if [ "$F1" = "72" ]
then
NC1=`expr $NC1 + 1`
elif
[ "$F1" = "76" ]
then
NC2=`expr $NC2 + 1`
elif
[ "$F1" = "78" ]
then
NC3=`expr $NC3 + 1`
fi
#


Rgds
Alexander M. Ermes
.. and all these memories are going to vanish like tears in the rain! final words from Rutger Hauer in "Blade Runner"
Henry Chua
Super Advisor

Re: Script for adding

Hi guys

I used Tripathy suggestion, but I have to initialise as well..

integer x=0
integer y=0
while(TRUE)
x=`awk '{ print $5 }' $BUF`
y=$y+$x
done

It work fine!!

ThankS !!!!