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

Some programs would prefer to output the help message in stderr. I want to search the help message with grep command, xx /? | grep regex?

How could i do this?

share|improve this question
up vote 4 down vote accepted

You can redirect stderr to stdout by using 2>&1, and then pipe stdout into grep.

So, what I think you want is this:

xx /? 2>&1 | grep regex
share|improve this answer
what does &1 means? – Jichao Jul 24 '12 at 5:00
To specify redirection to existing handles, use the ampersand & character followed by the handle number that you want to redirect (that is, &handle#). stdin is handle #0, stdout is handle #1, and stderr is handle #2. – martineau Jul 24 '12 at 5:12

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.