help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to pipe just stderr to stdin in a pipeline?


From: Andreas Kusalananda Kähäri
Subject: Re: How to pipe just stderr to stdin in a pipeline?
Date: Sun, 10 May 2020 21:43:48 +0200

On Sun, May 10, 2020 at 01:58:16PM -0500, Peng Yu wrote:
> That is not a pipeline. And, different from a pipeline, the status in
> >(cmd) can not be gotten easily.

Maybe you should have stated you requirements from the start?


> 
> On Sun, May 10, 2020 at 8:27 AM Pierre Gaston <address@hidden> wrote:
> >
> > you could do : somecommand 2> >(othercommand)
> >
> > On Sun, May 10, 2020 at 6:14 AM Peng Yu <address@hidden> wrote:
> >>
> >> But this an external command which can not run bash functions by
> >> definition. I need something native to bash.
> >>
> >> On 5/9/20, Pier Paolo Grassi <address@hidden> wrote:
> >> > take also a look at pipexec:
> >> >
> >> > https://github.com/flonatel/pipexec
> >> >
> >> >
> >> > Il giorno dom 10 mag 2020 alle 05:24 Peng Yu <address@hidden> ha
> >> > scritto:
> >> >
> >> >> Thanks. The original stdout must be redirected back to stdout (see
> >> >> "2>&1"). I have to use something like this to do it. This looks quite
> >> >> cumbersome.
> >> >>
> >> >> $ { { echo error 1>&2; echo out; } 3>&1 1>&2 2>&3 | awk -e '{ print
> >> >> "awk:", $0 }'; } 2>&1 | awk -e '{ print "awk2: " $0 }'
> >> >> awk2: out
> >> >> awk2: awk: error
> >> >>
> >> >> Is it better to add an operator similar to | and |& so that only
> >> >> stderr is piped to stdin of the next command in the pipeline?
> >> >>
> >> >> On Sat, May 9, 2020 at 10:11 PM Pier Paolo Grassi
> >> >> <address@hidden> wrote:
> >> >> >
> >> >> > I would use:
> >> >> >
> >> >> > {cmd1 3>&2 2>&1 1>&3 } | cmd2
> >> >> >
> >> >> > Il giorno dom 10 mag 2020 alle ore 05:04 Peng Yu <address@hidden>
> >> >> ha scritto:
> >> >> >>
> >> >> >> | pipes stdout to stdin in a pipeline
> >> >> >> |& pipes both stdout and stderr to stdin in a pipeline
> >> >> >>
> >> >> >> What is the best way to just pipe stderr (but not stdout) to stdin in
> >> >> >> a pipeline? Thanks.
> >> >> >>
> >> >> >> --
> >> >> >> Regards,
> >> >> >> Peng
> >> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Regards,
> >> >> Peng
> >> >>
> >> > --
> >> > Pier Paolo Grassi
> >> >
> >>
> >>
> >> --
> >> Regards,
> >> Peng
> >>
> 
> 
> -- 
> Regards,
> Peng

-- 
Andreas (Kusalananda) Kähäri
SciLifeLab, NBIS, ICM
Uppsala University, Sweden

.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]