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: Peng Yu
Subject: Re: How to pipe just stderr to stdin in a pipeline?
Date: Sat, 9 May 2020 23:14:43 -0500

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



reply via email to

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