Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I need to suppress some kind of output e.g.

foo | grep -v bar

But foo gives sometimes only:


grep will return -1. How do I transform the exit code 1 to 0?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You could always try piping it through something else, like cat, to get rid of the exit code from grep - though that may be a bigger hammer than you want.

share|improve this answer
and this seems even to be Posix compliant – math Jul 20 '10 at 16:10
You can also do || true if you're trying to bypass failure under set -e – Daenyth Jul 20 '10 at 16:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.