Friday, February 16, 2007

The pipe smokes

While this is not a tutorial on unix pipes , aka "|", one who uses this will notice that it does not work when dealing with output streamed to stderr...

i.e.

$cmd | cmd2
will work only on o/p of cmd that is streamed to stdout. This is a fundamental property of pipes - it will work on only one channel

A workaround to this is:
$cmd 2>&1 | cmd2

i.e. redirecting stderr to stdout, so that the pipe can read this.

No comments: