title: Grep regex NOT containing a string
body: <p>I am passing a list of regex patterns to <code>grep</code> to check against a syslog file. They are usually matching an IP address and log entry;</p>
  <pre class="lang-none prettyprint-override"><code>grep &quot;1\.2\.3\.4.*Has exploded&quot; syslog.log
  </code></pre>
  <p>It's just a list of patterns like the <code>&quot;1\.2\.3\.4.*Has exploded&quot;</code> part I am passing, in a loop, so I can't pass &quot;-v&quot;, for example.</p>
  <p>I am confused trying to do the inverse of the above, and <em>not</em> match lines with a certain IP address and error so &quot;!1.2.3.4.*Has exploded&quot; will match syslog lines for anything other than 1.2.3.4 telling me it has exploded. I <strong>must</strong> be able to include an IP address to <em>not</em> match.</p>
  <p>I have seen various similar posts on Stack Overflow. However, they use regex patterns that I can't seem to get to work with <code>grep</code>. What would be a working example for <code>grep</code>?</p>
  <p>This is happening in a script like this;</p>
  <pre class="lang-none prettyprint-override"><code>patterns[1]=&quot;1\.2\.3\.4.*Has exploded&quot;
  patterns[2]=&quot;5\.6\.7\.8.*Has died&quot;
  patterns[3]=&quot;\!9\.10\.11\.12.*Has exploded&quot;
  
  for i in {1..3}
  do
    grep &quot;${patterns[$i]}&quot; logfile.log
  done
  </code></pre>