try a for loop:
for x in 1 2 3 4
n=0
do
n=`echo $x+$n`|bc
done
Integer arithmetic can be done in the shell itself without requiring an external program, making the operation much faster:
n1=123
n2=543
sum=$(( $n1 + $n2 ))
echo "$sum"
Chat with our AI personalities