title: Awk scripting help - Logic Issue
body: <p>I'm currently writing a simple .sh script to parse an Exim log file for strings matching " o' ". Currently, when viewing output.txt, all that is there is a 0 printed on every line(606 lines). I'm guessing my logic is wrong, as awk does not throw any errors.</p>
  
  <p>Here is my code(updated for concatenation and counter issues). Edit: I've adopted some new code from dmckee's answer that I'm now working with over the old code in favor of simplicity.</p>
  
  <pre><code>awk '/o'\''/ {
           line = "&gt; ";
           for(i = 20; i &lt;= 33; i++) {
             line = line " " $i;
           }
           print line;
      }' /var/log/exim/main.log &gt; output.txt
  </code></pre>
  
  <p>Any ideas? </p>
  
  <p>EDIT: For clarity's sake, I'm grepping for "o'" in email addresses, because ' is an illegal character in email addresses(and in our databases, appears only with o'-prefixed names).</p>
  
  <p>EDIT 2: As per commentary request, here is a sanitized sample of some desired output:</p>
  
  <pre><code>[xxx.xxx.xxx.xxx] kathleen.o'toole@domain.com &lt;kathleen.o'toole@domain.com&gt; routing defer (-51): retry time not reached
  
  [xxx.xxx.xxx.xxx] julie.o'brien@domain.com &lt;julie.o'brien@domain.com&gt; routing defer (-51): retry time not reached
  
  [xxx.xxx.xxx.xxx] james.o'dell@domain.com &lt;james.o'dell@domain.com&gt; routing defer (-51): retry time not reached
  
  [xxx.xxx.xxx.xxx] daniel_o'leary@domain.com &lt;aniel_o'leary@domain.com&gt; routing defer (-51): retry time not reached
  </code></pre>
  
  <p>The reason I'm starting at 20 in my loop is because everything before the 20th field is just standard log information that isn't needed for my purposes here. All I need is everything from the IP and beyond for this solution(the messages for each 550 error are different for each mail server in use out there. I'm compiling a list of common ones)</p>