How can I run a command-line application in the Windows command prompt and have the output both displayed and redirected to a file at the same time?
If, for example, I were to run the command dir > test.txt
, this would redirect output to a file called test.txt
without displaying the results.
How could I write a command to display the output and redirect output to a file in the Windows command prompt, similar to the tee
command on Unix?
To expand on davor's answer, you can use PowerShell like this:
powershell "dir | tee test.txt"
If you're trying to redirect the output of an exe in the current directory, you need to use .\
on the filename, eg:
powershell ".\something.exe | tee test.txt"