I'd like to do different things to the stdout and stderr of a particular command. Something like
cmd |1 stdout_1 | stdout_2 |2 stderr_1 | stderr_2
where stdout_x is a command specifically for stdout and stderr_x is specifically for stderr. It's okay if stderr from every command gets piped into my stderr commands, but it's even better if the stderr could be strictly from cmd
. I've been searching for some syntax that may support this, but I can't seem to find anything.
The most straightforward solution would be something like this:
The main drawback being that if
gets_stdout
itself has any output on stdout, that will also go togets_stderr
. If that is a problem, you should use one of anubhava's or Kevin's answers.You can make use of a different file descriptor:
Example:
Or else use process substitution:
Example:
to pipe stdout and stderr separately from your
cmd
.You can use process substitution and redirection to achieve this: