Sum columns

Hi All,

I'm new to this forum. So please be patience with me! :slight_smile:
I have a file that looks like this (all rows have the same number of columns):

19 20 30 15 17 38 51 60 74 85 96 07 ....
10 20 44 59 39 88 13 77 30 10 11 12 ....
.
.
.

I want to sum the value of first field to all the remaining ones for every rows. So, for NR==1, all the values (after the first field) will be summed by 19; and for NR==2, all the values (after the first field) will be summed by 10 and so on...

Thanks a lot.

Best

Aderson Nascimento

try:

awk '{for (i=2; i<=NF; i++) { $i+=$1 } ; print $0}' infile

Same, but looks shorter(for Gawk)

awk '{for (i=2;++i<=NF;)$i+=$1}1'  infile