tail -f equivalent on Windows

As a longtime Unix and Linux guy, I always find myself looking for similar equivalents in the Windows space now that I’m doing so much C# .net work.  One thing I do a lot is look at the end of log files from my applications to see what’s happening.  In *nix you can do something like:

tail -f logfile

which shows you the last few lines of “logfile” interactively.  Meaning, that it will sit there and wait until “logfile” is appended to and it will then show you those lines.  It’s great for monitoring something sticky deep inside an application if you don’t have tests you can generate and run.

An equivalent to “tail -f” on Windows is to use PowerShell with this command:

Get-Content logfile -wait

Another nicety in PowerShell “Get-Content” is that you can pipe the output to a search to only show the logfile lines that contain a specific string:

Get-Content logfile -wait | where { $_ -match "searchString" }

Happy tailing!

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s