I'm trying to find where check_dns
is defined in nagios
' commands.cfg
file, although there are quite a few files.
I know I could run something like find / -name "command.cfg" -exec grep check_dns {} \;
to search for matches, but if possible I would like to use locate
since it is an indexed copy and much faster.
When I run locate commands.cfg
I get the following results:
/etc/nagios3/commands.cfg
/etc/nagiosgrapher/nagios3/commands.cfg
/usr/share/doc/nagios3-common/examples/commands.cfg
/usr/share/doc/nagios3-common/examples/template-object/commands.cfg
/usr/share/nagiosgrapher/debian/cfg/nagios3/commands.cfg
/var/lib/ucf/cache/:etc:nagiosgrapher:nagios3:commands.cfg
Is it possible to run locate and pipe it to an inline command like xargs
or something so that I can grep
each of the results? I realize this can be done with a for loop but I'm looking to pick up some bash-fu / shell-fu here more than how to do it for this specific case.