Perform floating point arithmetic in shell script variable definitions

May 16, 2013 in answer

0 votes, 0.00 avg. rating (0% score)

ANSWER:

You may not want to use bc for this. Perhaps awk would work better:

awk 'sum+=$1;ENDprint sum/NR' /path/to/file

Bruce Ediger from http://unix.stackexchange.com/questions/76069