title: AWK if inside for loop
body: <p>I am using a one liner awk to format a file in html</p>
  
  <pre><code>(awk -v var="$tLen" 'BEGIN {OFS="\t"; } { for(i=1;i&lt;=NF;i++) print "&lt;td align=center ROWSPAN=" var "&gt;" $i"&lt;/td&gt;"; } END {}' $part1file ) &gt;&gt; "$output"
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>&lt;td align=center ROWSPAN=4&gt;921&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;0&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;29128&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;0&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;4f9ea...b6c4a&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;11/09/2015_13:09:44&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;1&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;0&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;20&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;4&lt;/td&gt;
  </code></pre>
  
  <p>I need to return this:</p>
  
  <pre><code>&lt;td align=center ROWSPAN=4&gt;921&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;0&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;29128&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;0&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;4f9ea...b6c4a&lt;br/&gt;11/09/2015_13:09:44&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;1&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;0&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;20&lt;/td&gt;
  &lt;td align=center ROWSPAN=4&gt;4&lt;/td&gt;
  </code></pre>
  
  <p>Just on the end of the 5th line instead on closing the tag with  insert a <br/> then the next row data  and then close with </p>
  
  <p>I've tried something like</p>
  
  <pre><code>(awk -v var="$tLen" 'BEGIN {OFS="\t"; } { for(i=1;i&lt;=NF;i++) if (i==6)  print "&lt;br/&gt;"; else print "&lt;td align=center ROWSPAN=" var "&gt;" $i"; if (i==5) print ""; else  print "&lt;/td&gt;";  } END {}' $part1file ) &gt;&gt; "$output"
  </code></pre>
  
  <p>But it doesn't work. I seek help to make this if conditions to work inside the awk any light on this will be much appreciated.</p>