trying to make a basic addition function that adds the numbers entered and outputs a total. Here's my current function:
function addition() {
read -a arr
for i in ${arr[@]}
do
str=$str'+'$i
echo $i
done
echo $str
}
but this seems to ask for one input then outputs the above. I've also tried using:
function addition() {
for i in ${input[@]}
but that outputs an empty string. How do I go about creating a function that takes this command:
$ addition 4 3 13 40
into the function?