How Can I calculate the sum of a specific column using bash?

后端 未结 4 1416
长情又很酷
长情又很酷 2020-12-16 06:04

I want to calculate the sum of a specific column using bash without using the print that specific column (I want to keep all the output columns of my pipeline and only sum o

4条回答
  •  自闭症患者
    2020-12-16 06:20

    awk '{sum+=$1;} END { print "Total of 1st Column:" sum }1' abc.t6RrMm 
    

    Given a file like:

    12 12 12 
    1  1  1
    2  2  1
    0  1  2
    

    Total of 1st Column is 15.

提交回复
热议问题