title: Separate egrep output files by basename
body: <p>quite new in bash.
  I have some .txt files and I would like to receive the egrep output for all of them in the separated files, distinguished by their basename.
  Let’s say the initial files are AA.txt BB.txt and CC.txt. Each file has 100 lines content. There are two important lines including gene names “KRAS” and “BRAF” through AA, BB, and CC.</p>
  <p>I used:</p>
  <pre><code>data=&quot;*.txt&quot; for file in ./ do egrep 'KRAS|BRAF' $data &gt; zz.txt done exit;
  </code></pre>
  <p>Obviously it will give me one single file (zz), containing all three files’ (AA, BB, CC) egrep result.
  But what I want as the output is something like this:</p>
  <pre><code>file number1: AA.txt (containing just two lines with KRAS and BRAF).
  file number2: BB.txt (containing just two lines with KRAS and BRAF).
  file number3: CC.txt (containing just two lines with KRAS and BRAF).
  </code></pre>
  <p>Is there any command line to do it at once?</p>