Showing posts with label tip. Show all posts
Showing posts with label tip. Show all posts

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:
@ECHO OFF
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.

Example:

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

Monday, January 7, 2013

Clean Your Path

Note: This is a Windows tip!

Each time you install new software, especially nerdy, developer stuff, it tends to add itself to your system PATH. For single .exe programs (e.g. curl or git) I find this wasteful so I've devised a cunning plan. Let's say you install curl.exe in C:\some\folder\curl


  1. Remove the folder from your system path
  2. Create a curl.cmd text file in C:\windows\system32
  3. Edit this text file and add the following: C:\some\folder\curl\curl.exe %*
Now, open a DOS window and run curl google.com - it works! How?

  • %* passes all parameters on to curl.exe
  • C:\windows\system32 is always on your system path
I recommend doing this for all your favorite command line programs and even your favorite editor. My new favorite is Scripted!