title: Create file with egrep matches and file names
body: <p>I need some help...</p>
  
  <p>I'm creating a script of unit tests using shellscripts. That script, stores all the beeline calls from all files inside a directory.</p>
  
  <p>The script is doing it's purpose, but I don't wanna append the file name if grep does not return results.</p>
  
  <p>That's my code:</p>
  
  <pre><code>for file in $(ls)
  do 
  cat $file | egrep -on '^( +)?\bbeeline.*password=;"?' &gt;&gt; testa_scripts.sh
  echo $file &gt;&gt; testa_scripts.sh 
  done
  </code></pre>
  
  <p>How can I do that?</p>
  
  <p>Thanks</p>