Monday, December 5, 2016

View and Log Output with Tee

Ever wanted to view and log the output of a command at the same time? I'm sure it's available natively in Linux but not, AFAIK, in Windows. So we need a little tool.

Create a file called tee.cmd and save it somewhere in your PATH. The contents are as follows:
POWERSHELL -c "Tee-Object -FilePath %1"
Now just pipe your command to "tee" and pass the name of the file you want to log to.


DIR | tee op.txt
You will get a directory listing and it will also be logged to op.txt.

No comments:

Post a Comment