title: Redirecting grep to a file in the directory of search causes infinite recursion
body: <p>I'm trying to search the current directory recursively for the string <code>$level</code>. I want it to redirect the output to a file called <code>tmpfile2.txt</code>. When I try to do this, with  </p>
  
  <pre><code>grep -nr '\$level' . &gt; tmpfile2.txt
  </code></pre>
  
  <p>the file <code>tmpfile2.txt</code> grows without bound. The culprit seems to be that grep starts searching tmpfile2.txt and adding what it finds in tmpfile2.txt <em>to</em> tmpfile2.txt, so it recurs infinitely.</p>
  
  <p>Odder still, it seems I did this successfully not more than an hour ago, with a nearly identical command. The only difference was that it was <code>tmpfile1.txt</code> and there was no dollar sign in the search string. However, I just tried it without the dollar sign and it's still giving me the same problem.</p>
  
  <p>My questions are a) how can I solve this and b) is this the standard behavior of grep?</p>