title: How to get only filenames without Path by using grep
body: <p>I have got the following Problem.</p>
  
  <p>I´m doing a grep like:</p>
  
  <p>$command =    grep -r -i --include=*.cfg 'host{' /omd/sites/mesh/etc/icinga/conf.d/objects</p>
  
  <p>I got the following output:</p>
  
  <pre><code>/omd/sites/mesh/etc/icinga/conf.d/objects/testsystem/test1.cfg:define host{
  /omd/sites/mesh/etc/icinga/conf.d/objects/testsystem/test2.cfg:define host{
  /omd/sites/mesh/etc/icinga/conf.d/objects/testsystem/test3.cfg:define host{
  ...
  </code></pre>
  
  <p>for all *.cfg files.</p>
  
  <p>With <code>exec($command,$array)</code></p>
  
  <p>I passed the result in an array.</p>
  
  <p>Is it possible to get only the filenames as result of the grep-command.</p>
  
  <p>I have tried the following:</p>
  
  <pre><code>$Command=    grep -l -H -r -i --include=*.cfg 'host{' /omd/sites/mesh/etc/icinga/conf.d/objects
  </code></pre>
  
  <p>but I got the same result.</p>
  
  <p>I know that on the forum a similar topic exists.(<a href="https://stackoverflow.com/questions/6637882/how-can-i-use-grep-to-show-just-filenames-no-in-line-matches-on-linux">How can I use grep to show just filenames (no in-line matches) on linux?</a>), but the solution doesn´t work.</p>
  
  <p>With "exec($Command,$result_array)" I try to get an array with the results.
  The mentioned solutions works all, but I can´t get an resultarray with exec().</p>
  
  <p>Can anyone help me?</p>