logoalt Hacker News

emmelaichyesterday at 10:56 PM2 repliesview on HN

A gotcha for me originally and perhaps others is that while using ordering like

   $ ./outerr  >blah 2>&1
sends stdout and stderr to blah, imitating the order with pipe instead does not.

   $ ./outerr  | 2>&1 cat >blah
   err
This is because | is not a mere redirector but a statement terminator.

    (where outerr is the following...)
    echo out 
    echo err >&2

Replies

time4teayesterday at 11:44 PM

Useless use of cat error/award

But also | isnt a redirection, it takes stdout and pipes it to another program.

So, if you want stderr to go to stdout, so you can pipe it, you need to do it in order.

bob 2>&1 | prog

You usually dont want to do this though.

show 2 replies
inigyouyesterday at 11:11 PM

Why would that second one be expected to work?