title: Bash string (command output) equality test
body: <p>I have a simple script to check whether webpage contains a specified string. It looks like:</p>
  
  <pre><code>#!/bin/bash
  res=`curl -s "http://www.google.com" | grep "foo bar foo bar" | wc -l`
  if [[ $res == "0" ]]; then
      echo "OK"
  else
      echo "Wrong"
  fi
  </code></pre>
  
  <p>As you can see, I am looking to get "OK", but got a "Wrong".</p>
  
  <p>What's wrong with it?</p>
  
  <p>If I use if [ $res == "0" ], it works. If I just use res="0" instead of res=<code>curl...</code>, it also can obtain the desired results. </p>
  
  <p>Why are there these differences?</p>