I have a directory with executables and I want to search for a word in the output of the help messages of these executables, i.e. the text that is printed in the console after using the command ./executable1 --help. I want to output both the executable name and the occurrence of the searched text just like grep would do for a text file. How do I do this?
I managed something close with:
find -name "exec*" -executable -exec {} --help \; | grep "stringToBeSearchedFor" --
where find should have some criteria to find all the executables (in this example they all start with "exec" so this is appropriate).
However, this doesn't print the name of the executable with the match.