I've redirected output to a file like so:
$ ./test.bash 2> >(sed 's/^/stderr: /' >> output) > >(sed 's/^/stdout: /' >> output)
$ cat output
stdout: Hello World!
stderr: error
I would like to precisely reproduce the output of the original command ./test.bash
. This is what I tried:
$ cat output | tee >(grep '^stdout: '|sed 's/^stdout: //') >(grep '^stderr: '|sed 's/^stderr: //' 1>&2) >/dev/null 2>&1 | cat
error
Hello World!
Obviously, I would like the output to be in the right order. What is the best way to go about doing this?
Aucun commentaire:
Enregistrer un commentaire