title: Unstable bash statement
body: <p>I have the code in my bash scripts that works unstable:</p>
  
  <pre><code># check every line of check_list file presents in my_prog output
  MY_LIST=`./my_prog`
  for l in $(cat check_list); do
      if ! echo -n "$MY_LIST" | grep -q -x "$l"; then
          die "Bad line: '$l'"
      fi
  done
  </code></pre>
  
  <p>This piece of code of my huge scripting pool shows "Bad line: 'smthng'" with probability around 1/5000. I wasn't able to represent this event by the naked script but only in my huge scripting pool. </p>
  
  <p>However this code seems to work very fine:</p>
  
  <pre><code># check every line of check_list file presents in my_prog output
  ./my_prog &gt; my_list
  for l in $(cat check_list); do
      if ! grep -q -x "$l" "my_list"; then
          die "Bad line: '$l'"
      fi
  done
  </code></pre>
  
  <p>The reason why I don't like the second statement is that its use an intermediate file "my_list".
  What could be a problem of unstable working of the first statement? </p>