how to sum each column in a file using bash

前端 未结 5 1864
梦谈多话
梦谈多话 2021-01-22 14:19

I have a file on the following format

id_1,1,0,2,3,lable1
id_2,3,2,2,1,lable1
id_3,5,1,7,6,lable1

and I want the summation of each column ( I

5条回答
  •  甜味超标
    2021-01-22 15:08

    Using awk:

    $ awk -F, '{for (i=2;i

    This will print the sum of each column (from i=2 .. i=n-1) in a comma separated file followed the value of the last column from the last row (i.e. lable1).

提交回复
热议问题