From: hugo rivera <uair00@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] rc output redirection
Date: Fri, 3 Apr 2009 10:51:03 +0200 [thread overview]
Message-ID: <138575260904030151w532ab85ciec4af5499669d1f7@mail.gmail.com> (raw)
In-Reply-To: <dd6fe68a0904022213n44b2cc9dodd748d5396cfd119@mail.gmail.com>
2009/4/3, Russ Cox <rsc@swtch.com>:
> > But when you do something like
> > cmd1 | cmd2 |[2] cmd3
> > you get cmd1's stdout piped to cmd2's stdin; but my confusion begins
> > here: is it cmd1's or cmd2's stderr that gets redirected to cmd3's
>
> > stdin? maybe both? my guess is that ...
>
> why guess?
>
> % {echo cmd1 >[1=2]} | {echo cmd2 >[1=2]} | sed 's/^/cmd3: /'
> cmd1
> cmd2
> % {echo cmd1 >[1=2]} | {echo cmd2 >[1=2]} |[2] sed 's/^/cmd3: /'
> cmd3: cmd1
> cmd3: cmd2
> %
>
> not what i expected, but there you have it.
> and it makes sense: cmd1 and cmd2 are both
> writing to the same stderr, so redirecting it
> redirects both.
>
>
> > how can I redirect cmd1's stderr to cmd3's stdin instead
> > of cmd2's? or both?
>
>
> if you don't care about cmd2's stderr, then you can get rid of it
>
> % {echo cmd1 >[1=2]} | {echo cmd2 >[2]/dev/null} |[2] sed 's/^/cmd3: /'
> cmd2
> cmd3: cmd1
>
> %
>
> > It's easy to think of more complex cases.
>
>
> it's easy to think of elephants.
>
> rc does its general-purpose job very well.
> if you have special-purpose needs,
> as lucio suggests, write a c program.
>
>
> russ
>
>
ok, thanks
--
Hugo
prev parent reply other threads:[~2009-04-03 8:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-02 16:56 hugo rivera
2009-04-02 17:28 ` lucio
2009-04-03 5:13 ` Russ Cox
2009-04-03 8:51 ` hugo rivera [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=138575260904030151w532ab85ciec4af5499669d1f7@mail.gmail.com \
--to=uair00@gmail.com \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).