title: How do I redirect output to a variable in shell?
body: <p>I have a script like that</p>
  
  <pre><code>genhash --use-ssl -s $IP -p 443 --url $URL | grep MD5 | grep -c $MD5
  </code></pre>
  
  <p>I want to get stream generated by genhash in a variable. How do I redirect it into a variable <code>$hash</code> to compare inside a conditional?</p>
  
  <pre><code>if [ $hash -ne 0 ]
    then echo KO
    exit 0
  else echo -n OK
    exit 0
  fi
  </code></pre>