bug-bash
[Top][All Lists]
Advanced

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

bash 1-liner or function to tee to STDERR in middle of pipe?


From: bug-bash
Subject: bash 1-liner or function to tee to STDERR in middle of pipe?
Date: Fri, 03 Jul 2020 09:32:18 -0500

This does what I want: 

--8<---------------cut here---------------start------------->8--- 
_tee_stderr () 
{ 
     <<'____eohd'
    SYNOPSIS

        ourname

    DESCRIPTION

        Use in a pipe. Leaks STDIN to STDERR. Passes STDIN to STDOUT unchanged.

    EXAMPLE

        $ seq 5 |_tee_stderr |tail -2 > /tmp/bar ; echo;cat  /tmp/bar
        1
        2
        3
        4
        5

        4
        5

____eohd

    ( tmpf=$( mktemp ~/tmp/$FUNCNAME.XXX );
    cat > $tmpf;
    cat $tmpf 1>&2;
    cat $tmpf;
    rm -f $tmpf );
    return;
}
--8<---------------cut here---------------end--------------->8--- 

What is better/cleaner?

--
thanks!





reply via email to

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