I want to get an exit code only if a specific text is found in a set of log file.
If no matches are found, or no files are present the command should pass successfully.
Grep should be silent, as I don't want to see the matches. I only want to know if the pattern was found (using exit code).
Somehow it seems that if use quiet mode to silence grep, the result code will always be success.
grep --silent hm /etc/passwd
returns1
, as expected. If that's not working for you, you can always discard stdout/stderr.