I want a script to calculate the sum of the numbers entered by the user.
so far I have:
#!/bin/bash
add() {
sum=0
for num
do
sum=$((sum +num))
done
}
echo "$sum"
the command I use is:
add 4 -3 9 12
the return is: blank line - not the words just a blank line username~/folder:>
what am I missing?
permissions are rwxr xr x
I'm running an interactive shell with the folder in my path, I'm at a loss.
add()
, does not do anything with it, then echoes the unset variable$sum
. – AlexP Dec 20 '17 at 03:04