For example, I have a file:
$ cat test.file
a
b
c
If I grep with output, I got echo $? to 0:
$ grep a test.file
a
$ echo $?
0
But if I grep without output, I got echo $? to 1
$ grep x test.file
$ echo $?
1
Because I got $? to 1, my pipeline with this command is failed.
What should I do to get consistent result as 0, since grep has no output is fine to me.
Simply add an
or trueand the end