Windows: Command line redirection to text file while also seeing output

The windows PowerShell has a tool that can do that, named tee after the unix tool which does the same.

Alternatively, there are ports of the unix tee for windows:

  • GNU utilities for Win32 (last update 2003)
  • CoreUtils for Windows (last update 2005)

Under Windows all I can think is to do this:

myProgram.exe > mylog.txt & type mylog.txt

This is based on the command example in your question - if in fact you wanted to append the output to mylog.txt then you'd want to use >> instead of >, but type would print out the entire log file, not just what had been appended.

If you download the GnuWin32 CoreUtils, you can use the Unix method (tee command) for doing this:

myProgram.exe | tee mylog.txt

This will write the output of myProgram.exe to mylog.txt but also display it to the console at the same time. If you only want to append to mylog.txt then you can pass the -a parameter to tee.