One thing that I constantly need and can never remember the syntax for is redirecting stdout and stderr in a Windows batch file or cmd script (actually, the syntax is pretty much the same for *nix shell scripts).
Rather than just a one-sentence note here to remind me, I’ll write a few more sentences as explanation. Hopefully this will save someone a little bit of time
For starters, you can redirect the output of a command to a file like so:
blah.exe > output.txt
That example will overwrite any pre-existing output.txt file. If you want to append to the file, use:
blah.exe >> output.txt
But this only redirects “standard output” (stdout). If your program encounters an error, the output generated by the error condition probably won’t show up in the file. If you want it to show up in the file, redirect “standard error” (stderr) also like so:
blah.exe 2>&1 output.txt
At the moment, I can’t tell you if that will append or overwrite. I’ll check that out and update the post…