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: errorI 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?
Store stdout and stderr in file, then recreate the output later
io redirection;storage;stdout;file descriptors
Depending on your current file probably this would do:awk '    /^stdout:/ { print substr($0, 9) }     /^stderr:/ { print substr($0, 9) > /dev/stderr }    ' outputIt could get a bit more elegant with some changes to your recording script.