title: AWK issue : counting "non-matches"
body: <p>I want to count the occurrences of some words in a file. Then I modify my code to additionally count how many lines did not match to any word.</p>
  <p>For example here is my input file (test.txt):</p>
  <pre><code>fred
  fred
  fred
  bob
  bob
  john
  BILL
  BILL
  </code></pre>
  <p>Here is my code:</p>
  <pre><code>awk '
      /fred/ { count[&quot;fred&quot;]++ }
      /bob/ { count[&quot;bob&quot;]++ }
      /john/ { count[&quot;john&quot;]++ }
     END      { for (name in count) print name, &quot;was found on&quot;, count[name], &quot;lines.&quot; }
     ' test.txt
  </code></pre>
  <p>This works fine and gives me this output:</p>
  <pre><code>john was found on 1 lines.
  bob was found on 2 lines.
  fred was found on 3 lines.
  </code></pre>
  <p>Now I want to get a count of the lines that didn't match so I did the following code:</p>
  <pre><code>awk '
      found=0
      /fred/ { count[&quot;fred&quot;]++; found=1 }
      /bob/ { count[&quot;bob&quot;]++; found=1 }
      /john/ { count[&quot;john&quot;]++; found=1 }
      if (found==0) { count[&quot;none&quot;]++ }
     END      { for (name in count) print name, &quot;was found on&quot;, count[name], &quot;lines.&quot; }
     ' test.txt
  </code></pre>
  <p>I get an error on the if statement like this:</p>
  <pre><code>awk: syntax error at source line 6
   context is
          &gt;&gt;&gt;  if &lt;&lt;&lt;  (found==0) { count[&quot;none&quot;]++; }
  awk: bailing out at source line 8
  </code></pre>
  <p>Any ideas why this isn't working?</p>