我有以下问题.
我正在做一个grep:
$command = grep -r -i –include = * .cfg’host {‘/ tomd / sites / mesh / etc /icinga / conf.d / objects
我得到以下输出:
/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{
...
对于所有* .cfg文件.
使用exec($command,$array)
我在数组中传递了结果.
是否可以仅获取grep-command的文件名.
我尝试过以下方法:
$Command= grep -l -H -r -i --include=*.cfg 'host{' /omd/sites/mesh/etc/icinga/conf.d/objects
但我得到了同样的结果.
使用“exec($Command,$result_array)”,我试着得到一个包含结果的数组.
提到的解决方案可以解决所有问题,但是我无法使用exec()得到一个resultarray.
谁能帮我?