Is there any way, in bash, to pipe STDERR through a filter before unifying it with STDOUT? That is, I want
STDOUT ────────────────┐
├
A naive use of process substitution seems to allow filtering of stderr
separately from stdout
:
:; ( echo out ; echo err >&2 ) 2> >( sed s/^/e:/ >&2 )
out
e:err
Note that stderr
comes out on stderr
and stdout
on stdout
, which we can see by wrapping the whole thing in another subshell and redirecting to files o
and e
( ( echo out ; echo err >&2 ) 2> >( sed s/^/e:/ >&2 ) ) 1>o 2>e