I have a function test1 which produces output on both stdout and stderr:
test1() {
echo "out 1"
sleep 0.1
echo "error 1" 1>&2
sleep 0.1
echo "out 2"
sleep 0.1
echo "error 2" 1>&2
sleep 0.1
}
I then have two aliases which format stdin and send it to stdout:
alias o='sed -E "s/^/O /"'
alias e='sed -E "s/^/E /"'
How can I pipe the two streams from test1 through o and e and end up with formatted output on stdout and stderr? I'm using Bash on Alpine Linux, so GNU utilities are not an option.
My reasoning goes as follows, but I don't know how to execute it syntactically:
- Send
errtooutandoutto3. - Run
inthroughe, send toerrand3toout. - Run
inthrougho. - Profit?
test1 > >(o) 2> >(e >&2)?