Issue
Why does grep returns a non-zero value when there is a HIT?
Aren't non-zero values supposed to be for unsuccessful command executions?
Solution
Here is what you can find in the man page of the grep command :
Exit Status grep exits with one of the following values:
0 One or more lines were selected.
1 No lines were selected.
>1 An error occurred - syntax error in pattern, inaccessible input files, or other system error. In other words a failure to find a matching item is reported as an error (1)
The '-v' option can be used to effectively invert the exit status.
So, there are several answers to your question depending on the command you entered. If you want more help, edit your post with the complete command / process used.
Answered By - Jeriko Answer Checked By - Marie Seifert (WPSolving Admin)