Comments on Capture separate _and_ combined stdout/stderr
Post
Capture separate _and_ combined stdout/stderr
+5
−0
Using BASH, how can I redirect stdout and stderr each, to two separate files, simultaneously?
That's a mouthful, let me clarify a little:
I have a hypothetical script that may/will generate output on both stdout and stderr. I want to run the script and wind up with three output files:
- The contents of stdout only (
>stdout.txt
). - The contents of stderr only (
2>stderr.txt
). - The combined contents of stdout and stderr, interleaved as they would have been had they been printed to the terminal in real time (
>both.txt 2>both.txt
).
With Zsh you can do something like this with MULTIOS
enabled:
script.txt >stdout.txt >>both.txt 2>stderr.txt 2>>both.txt
...but I need something that'll work on systems that don't have Zsh installed.
1 comment thread