Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 2 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
1  
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
add comment

Your Answer

 
discard

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.