Redirecting error output on windows console

I thought I already blogged this, but I can’t find it back, so let me try one more try as I seem to need this from time to time and then fail to remember the correct syntax! 🙂

The scenario is: you have this huge error output on your console (for example a very long compiler error). Since it is quite long, console history is not big enough to see the beginning. You could of course increase the history size, but it’s not a real solution. Everyone knows how to redirect console output to a file, simply like this:

type myhugefile.txt > output.txt

This is all nice and dandy, except, it doesn’t capture the error output (stderr) (which is exactly what we’re interested in ;)). You have to do some win32 console-fu as follows:

mingw32-make 1> output.txt 2>&1

This tells the shell to redirect standard output (stdout) to output.txt and redirect error output to standard output.

You can read all this information in a nice collegebook format on MS’s KB.

Leave a Reply

Your email address will not be published. Required fields are marked *