title: Using awk to calculate an average of numbers
body: <p>I have a file named <code>test.txt</code> with the following:</p>
  
  <pre><code>10
  200
  3000
  =======
  4
  5
  =======
  </code></pre>
  
  <p>I need to write an awk script to take the text in this file as input into the awk script and output:</p>
  
  <pre><code>10
  200
  3000
  
  Average 1070.00
  
  4
  5
  
  Average 4.50
  </code></pre>
  
  <p>I wrote my script  like this:</p>
  
  <pre><code>{while($1!~"=======") s+=$1;}
  {print "Average ", s}
  </code></pre>
  
  <p>Every time I run this code, I use:</p>
  
  <pre><code>awk -f awrp4 test.txt
  </code></pre>
  
  <p>But it crashes. I don't know what I'm doing wrong. I'm a beginner and trying to learn about the awk function so I apologize if this seems rather simple. Any help is welcome.</p>