I have the grep
command. I'm searching for a keyword from a file, but I don't want to display the match. I just want to know the exit status of the grep
.
How to Suppress Output from grep and Only Return Exit Status
grepscriptingshell-script
grepscriptingshell-script
I have the grep
command. I'm searching for a keyword from a file, but I don't want to display the match. I just want to know the exit status of the grep
.
Best Answer
Any POSIX compliant version of
grep
has the switch-q
for quiet:In GNU grep (and possibly others) you can use long-option synonyms as well:
Example
String exists:
String doesn't exist: