Wednesday, April 8, 2009

Sending stderr (Standard Error) to Pipe

Many times we want to send output of standard error (stderr)
to pipe '|', so that we can use it as input for another command.

For example, while compilation of program, we are mostly interested
in error/warning messages. We can not get those lines by following
command:

$ make | egrep -i "error|warning"

so how can we can get only those error/warning message lines. We
just need to bind stderr (file handle 2) with stdout (file handle 1).
"2>&1"
The following example shows this:

$ make 2>&1 | egrep -i "error|warning"


No comments: