Average of list of floating point numbers Bash
I am trying to find the average of a bunch of floating point numbers from a file using bc in b开发者_开发技巧ash.
right now, when I add I use:
let "sum=sum+${NUMBERS[$i]} | bc"
` I get syntax errors when I do this however. Syntactically, what is wrong with this?
bc is expecting standard input. Since the first command has no standard output, bc has no input in this case. Try this:
sum=`echo $sum+${NUMBERS[$i]} | bc -l`
精彩评论