Thomas Güttler Mailinglisten <guettl...@gmail.com> writes:
> Hi Dale, thank you for your reply. Currently, I work around like this:
>
> echo -e "foo\nbar" | { grep '^#' >comments.txt || true; } |
> some-other-command

The difficulty with that code is that it doesn't satisfy the requirement
you stated:

> Afaik there is no option to make `grep` always exit with a zero exit
> status. No matter if a match was found or not. Errors like "file not found"
> should still return a non-zero exit status.

That's why you need the test "$? != 2".

Dale



Reply via email to