Compute the Average

  • + 13 comments

    Short and crisp

    read n
    arr=($(cat)) 
    arr=${arr[*]}
    printf "%.3f" $(echo $((${arr// /+}))/$n | bc -l)