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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 6 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.