How do I calculate the mean of a column

后端 未结 5 1194
花落未央
花落未央 2020-12-25 10:42

Anyone know how can I calculate the mean of one these columns (on linux)??

sda               2.91    20.44    6.13    2.95   217.53   186.67    44.55     0.         


        
5条回答
  •  抹茶落季
    2020-12-25 11:20

    Awk:

    awk '{ total += $2 } END { print total/NR }' yourFile.whatever
    

    Read as:

    • For each line, add column 2 to a variable 'total'.
    • At the end of the file, print 'total' divided by the number of records.

提交回复
热议问题