Thursday, June 20, 2013

Tailing a File in Windows

There is an easy and very useful command in most Minix systems called tail.  Essentially tail shows the last bit of a file.  This can be really handy when you're trying to read a log file with 10,000 lines in it.  You can use tail to view the last 10 lines in the file.  While no such command exists for the native Windows command interpreter, there is an option in Windows PowerShell.  It's pretty easy to use and since PowerShell is built into all Windows systems XP and later, it's a handy way to get similar functionality without having to download or install anything.
However, the command isn't called tail, it's called Get-Content.  Here are some good examples and some of the options.  The one I like is:

This returns all lines of the file specified in [filename] and waits for the file to be changed.  When the file changes, the display is updated.  This is great for when you want to watch a log file for new entries.