How can I save stdout to one file, stderr to another file, stdout+stderr to a third file and also get stdout + stderr to terminal like normal for a shell script?
I found this elsewhere:
exec > >(tee std_out) 2> >(tee err_out >&2)
ls # Should got to std_out
fsdfs # Command not found goes to err_out
Which is really close. If I run bash test.sh 2>&1 | tee output
then it works, but I don't have access to how my script is run. It's a cicd system. I need to be able to do the "combined output" from inside the script using exec.
I'm creating a CI/CD library and I'm unable to know what the clients would use the library for, so I want to account for each use case.