title: sed- delete line that doesn't contain a pattern
body: <p>I'm surprised that I can't find a question similar to this one on SO.</p>
  
  <p>How do I use sed to delete all lines that do not contain a specific pattern.</p>
  
  <p>For example, I have this file:</p>
  
  <pre><code>cat kitty dog
  giraffe panda
  lion tiger
  </code></pre>
  
  <p>I want a sed command that, when called, will delete all lines that do not contain the word <code>cat</code>:</p>
  
  <pre><code>cat kitty dog
  </code></pre>