title: Apply a calculation on columns (awk)
body: <p>I tried to make this calculation from the column 41 to the end of the line:</p>
  
  <pre><code>    awk '{ { split($10,a,":") } { split( a[4], b ,",") } {print b[1]+b[2]}}' filename
  </code></pre>
  
  <p>I know how to do this on just one column, but when I tried to do a loop it fails :</p>
  
  <pre><code>     awk '{for (i=10;i&lt;=NF;i++) {split($i,a,":")} {split(a[4],b,",")} {print ( b[1]+b[2])}}' filename
  </code></pre>
  
  <p>The aim is to split each columns and to do the sum of those numbers : </p>
  
  <blockquote>
    <p>./.:0:.,.,.:<strong>0,0</strong>:0,0</p>
  </blockquote>
  
  <p>Here is what my file looks like :</p>
  
  <pre><code>Contig  POS  ID  REF  ALT  QUAL  FILTER  INFO  FORMAT  S155  S158  S168  S173  S175  S178  S180  S188  S189  S191  S193  S194  S196  S201  S205  S206  S208  S209  S210
  NODE_14985_length_2800_cov_1.38384 67 999978 A C . PASS Ty=SNP;Rk=1;UL=19;UR=31;CL=.;CR=.;Genome=A;Sd=1 GT:DP:PL:AD:HQ ./.:8:.,.,.:8,0:71,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0    ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0    ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0     ./.:0:.,.,.:0,0:0,0
  </code></pre>
  
  <p>Here is my actual output:</p>
  
  <pre><code>awk '{for (i=10;i&lt;=NF;i++) {split($i,a,":")} {split(a[4],b,",")} {print b[1]+b[2]}}' file.vcf | head
  
  0
  0
  0
  0
  0
  </code></pre>
  
  <p>I want a matrix of the calcul for each columns :</p>
  
  <pre><code>0 0 0 0 
  1 2 0 6
  2 0 0 8 
  ...
  </code></pre>
  
  <p>Thank you in advance for your help </p>