I am trying to write my first shell script for a class. The goal is to take a list of integers as a command line argument and display their squares and the sum of the squares. I am getting an error that the arguments are not being found.
This is the piece that is giving the error that the arguments are not found:
sumsq=0 #sum of squares
int=0 #Running sum initialized to 0
count=0 #Running count of numbers passed as arguments
while [ $# != 0 ]
do
numbers[$int]=`expr $1` #Assigns arguments to integers
let square=`expr $1*$1` #Operation to square arguments
squares[$int]=$square #Calc. square of each argument
sumsq=`expr $sumsq + $square` #Add square to total
count=`expr $count + 1` #Increment count
shift #Remove the used argument
int=`expr $int + 1` #Increment to next argument
done
I am using dash shell.