2 edited tags
| link
1
source | link

How to add the number in one column based on the numbers in other columns

I have a tab-delimited dataset like:

#1 2      3   4  5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1 10024 10395 41 K + 2 1 1 12 14  5  0  0  3  1  3  6 2 
1 10679 10795 51 P + 2 1 1 15 14  3  0  0  2  1  2  3 1 

I want to add one more column ($20) to store the values based on column 7-19: if the number in a column is not equal to 0, then plus one. Expected output:

#1 2      3   4  5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 10024 10395 41 K + 2 1 1 12 14  5  0  0  3  1  3  6 2  11
1 10679 10795 51 P + 2 1 1 15 14  3  0  0  2  1  2  3 1  11

How to write the command using awk?