I'm running a memory check tool (prog1) on a C++ code (prog2), both of which give me a huge and detailed output. In order to chase down some bugs I need to save this output to a file.
I tried redirecting the stdout to a file:
prog1 prog2 > outfile.txt
But that gives me a file containing the output of prog2, while the output of prog1 is still going to the terminal.
Anyone know a way to specify that I want BOTH outputs to go to a file? Like (prog1 prog2) > outfile.txt
?
2>&1
has to go after> outfile.txt
. Order of redirections matter. – Barmar Dec 17 '18 at 17:14echo >&2 hello world
is equivalent toecho hello world >&2
. More info here: https://www.tldp.org/LDP/abs/html/io-redirection.html – Morgen Dec 18 '18 at 04:28