title: Calculate avg of a row using awk
body: <p>I have been working a script that calculates avg of a rows by reading input from a txt file</p>
  
  <p>sample text input file <strong>input.txt</strong></p>
  
  <pre><code>157361 155687 156158 156830
  149610 151824 152353 152027
  159195 158490 159030 159243
  153222 154227 154578 154390
  168761 170078 170044 170107
  147166 146477 146735 147678
  155745 152142 155141 154140
  148860 150040 149223 148246
  147239 149693 148144 147990
  148045 147987 149466 149535
  146945 146206 145681 145852
  156559 155188 156274 154962
  143169 143798 142753 144045
  153814 153320 153732 156621
  </code></pre>
  
  <p>I'm working on the below awk command:</p>
  
  <pre><code>awk '{sum=0; for(i=0; i&lt;=NF; i++){sum+=$i}; sum/=NF; print sum}' input.txt
  </code></pre>
  
  <p>i'm getting 156679 as expected result for row1 avg:"somewhere its reading blank space as variable) with the above awk expression.</p>
  
  <pre><code>cal row1 excpected avg would be :(157361+155687+156158+156830)/4 = 156509
  </code></pre>
  
  <p>Im not getting expected output the avg am geting is wrong expected avg's for the above input file</p>
  
  <pre><code>row1 expected avg :156509
  row2 expected avg :151454
  </code></pre>