Hi-
Here is the shell script that for some reason is not returning results:
#! /bin/ksh -
avg() {
AVG=0
typeset SUM=0
if [ "$#" -lt 2 ]
then
echo "You must have at least two numbers"
else
for NUM in "$*"
do
SUM=$(( SUM + $NUM ))
echo "SUM: $SUM + $NUM"
done
AVG=`echo "scale=2; $SUM/$#"|bc`
fi
}
ANS=$(avg $*)
echo "Average of $@ is $ANS"
If you run it would simply say "Average of numbers (list the numbers) is"
and give me this error
"./avg.sh: line 13: SUM + 5 2 : arithmetic syntax error"
Thanks