How do I redirect my program, so that the output goes to 3 file such that
- stdout goes to file1
- stderr goes to file2
- the combined result of stdout and stderr goes to file3 in their original order
- While redirecting, the output is also printed to the screen as the program is running
I tried
myprogram > file1 2> file2
but this does not satisfy 3 & 4.
Edit: It would be better if the screen displays messages immediately after they are printed. (to increase responsiveness)