Stack Overflow archive
0 score

UNIX: How do I make my script return the sum of the numbers passed to it from the command line?

score
0
question views
176
license
CC BY-SA 3.0

Another answer:

bash
sum=0
for i in $@
do
    sum=$(($sum + $i))
done
echo $sum

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.