I have a text input like this:
TOKEN=32141234134143
ERROR=this is an error
The above two line will not occur at the same time. i.e. either TOKEN or ERROR but not both.
I use grep
on the above input like this:
cat input |grep TOKEN
If there are error, the output will be nothing. What I want is that no matter what the text is, grep only match for the regex but not filter the text, if match is not found grep simply returns an non-zero exit code.
Is that possible, or any other command line tool to do this?
EDIT: I want the output of grep to be ALL input text, including non-matching linese, not NONE text, which the -q
option of grep gives.