[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] counting up in bash






I write some bash scripts and need to do some calculations. For example I have a file containing the 3 following lines:

15
25
20

I need to have the number 60, as their sum, in some variable. How should I do that? Could somebody tell me which tool and how to use?

In ksh:

----
sum=0
while read i
do
	let sum=sum+i
done

echo $sum
return $sum
----

Redirect stdin with <.

Should do in bash also.

-Helmut