Avoid "++ requires lvalue" Error in Loop Calculation

Hi All,

Please help me to perform sum of values in a loop, I am getting following error:

"total=0++432907765772: ++ requires lvalue"

where actual statement is as : total=$total+$amt

where amt can have +ve or -ve values

Thanks
Sandeepb

The convention is that a number that has no leading sign is positive.

Hence if the string has a leading + then it is redundent, I suggest you strip it off with sed or something.

Hi ,

Can some one please provide me an example code?

Thanks
Sandeep

$ echo "+01234" | sed "s/+//"
01234