shell script + numbers sum

lidia picture lidia · Sep 3, 2010 · Viewed 50.3k times · Source

what the best simple elegant way to sum number in ksh or bash my example is about let command , but I want to find better way to summary all numbers

for example

num1=1232
num2=24 
num3=444
.
.
.

let SUM=$num1+num2+num3.........

Answer

codaddict picture codaddict · Sep 3, 2010

How about:

num1=1232
num2=24 
num3=444
sum=$((num1+num2+num3))
echo $sum # prints 1700