I have a file which has sections with different tables. I want to sum all the values contained within each column with the header N*dNFor example:omega (dN/dS) = 999.00000dN & dS for each branch branch          t       N       S   dN/dS      dN      dS  N*dN  S*dS  11..6      0.000   532.0   266.0 999.0000  0.0000  0.0000   3.0   0.0  11..7      0.000   532.0   266.0 999.0000  0.0000  0.0000   4.0   0.0  11..12     0.000   532.0   266.0 999.0000  0.0000  0.0000   0.5   0.0omega (dN/dS) = 1.00000dN & dS for each branch branch          t       N       S   dN/dS      dN      dS  N*dN  S*dS  11..6      0.000   532.0   266.0 999.0000  0.0000  0.0000   7.0   0.0  11..7      0.000   532.0   266.0 999.0000  0.0000  0.0000   2.0   0.0  11..12     0.000   532.0   266.0 999.0000  0.0000  0.0000   0.4   0.0Desired output:7.59.4Maybe some modification of awk '{s+=$8}END{print s}'where I can specify the title of the column and make it print the separate results of each sum, not the sum of the sums...
Sum all values in a column with an especified header
text processing;bioinformatics
You can use awk in this way (assuming the content are always followed by the matched header and same counts in all + no empty lines happened between them).awk 'f{s+=$8;f++} ($8==N*dN){f=1} (f>4){print s;f=s=0}' infileOr in general case, use it as like below. It will sum till next N*dN seen in column#8:awk 'f{s+=$8} (f &&$8==N*dN){print s;f=s=0} ($8==N*dN){f=1} END{print s}' infile