Hello,
I need to sum the values of several columns but want to avoid the $1+$2+$3...+$100 syntax.
I tried the command below, but apparently I'm doing something wrong.
wanted result
I need to sum the values of several columns but want to avoid the $1+$2+$3...+$100 syntax.
I tried the command below, but apparently I'm doing something wrong.
Code:
$ cat infile
1 2 3
4 5 6
wanted result
Code:
6
15
Code:
$ awk -F "\t" '{x=0; for (i=1; i<=NF; i++); x = x + $i; print x }' infile
0
0