Whats up fellas, I am new here... just wanted to see if anyone knew a way to get an avergage of a list of numbers... I am trying to use bc (number of records in file divided by sum of all records in file) but it is not giving me accurate data.
IE:
------------------------------------------------------------
COUNT=`wc -l $datafile | awk '{print $1}'`
SUM=`sumfld $datafile 2 | awk '{print $NF}' #sumfld is internal utilty to add contents of datafile's feild
AVG=`echo "$SUM / $COUNT" | bc`
-------------------------------------------------------------
I find that if the $COUNT=2, and $SUM=9.99, $AVG should be be about 4.995, but instead it just returning 4. Any help would be appreciated.