title: bash: wget stdout to grep "word" if not exist grep "word2" print word|word2
body: <p>I recently came across a new website called pwnedlist.com, it keeps track of compromised e-mail accounts.</p>
  
  <p>I figured it would be a good practice exercise for me to try and query each email from a list.</p>
  
  <p>I have all that done, fine and dandy, but my issue is that I don't know a good method for
  have the stdout pass through both grep's without wget'ing a second time for the second string. Here's what I have so far....</p>
  
  <pre><code>    #!/usr/local/bin/bash
  
      if [ -z "$1" ]
      then
              echo "Usage: $0 &lt;list&gt;"
      exit
      fi
  
      for address in $(cat $1)
      do
  
      echo -n "$address       "
      wget -O - --post-data "query_input=$address" pwnedlist.com/query 2&gt;/dev/null |
      grep -i congrats | cut -d '&gt;' -f 2 | cut -d '&lt;' -f 1
  
      done
      echo
  </code></pre>
  
  <p>This works like I want it to:</p>
  
  <pre><code>    $ ./querypwnlist testfile
      jonschipp@gmail.com     Congrats! Your email is not in our list.
      somebody@somebody.com   Congrats! Your email is not in our list.
      crap@crap.com           Congrats! Your email is not in our list.
  </code></pre>
  
  <p>My issue is that I need to find a way to grep for the other parameter, the not-so-good one</p>
  
  <pre><code>   grep -i "we found"
  </code></pre>
  
  <p>is the string I need.</p>
  
  <p>Here's the HTML:</p>
  
  <pre><code>   &lt;div id="query_result_negative" class='query_result_footer'&gt;... we found your email/username in our database. It was last seen on 2011-08-30. Please read on.&lt;/div&gt;
  </code></pre>
  
  <p>I tried this in hopes that it would print those "compromised" emails as well but it didn't work, my logic is incorrect.</p>
  
  <pre><code>   wget ..... | ( grep -i congrats || grep -i "we found" ) | cut ....
  </code></pre>
  
  <p>Also, my choice of cut options looks kinda bulky/superfluous, any ideas for something cleaner? Using one command instead of sending it through cut a second time? </p>
  
  <p>Here's the HTML:</p>
  
  <pre><code>    &lt;div id="query_result_negative" class='query_result_footer'&gt;Congrats! Your email is not in our list.&lt;/div&gt;
  </code></pre>
  
  <p>Any help is appreciated, thanks!</p>