Unix-like Tail function in Windows without installing new software

Windows Powershell has a powerful command that lets you view the last lines of a text file or even monitor it for new lines, similar to tail -f command in Linux. Here’s some examples:

 

The following will view the last 10 lines of Apache’s log file:

PS c:\apache\logs> gc access.log -last 10

The following will view the whole apache log file and when done, will continue waiting for new entries:

PS c:\apache\logs> gc access.log -wait

Of course the previous example is not very useful if your log file is already large, so you can combine the two commands and skip to the last lines like this:

PS c:\apache\logs> gc access.log -wait -last 10

Until I discovered the above command I used Tail Win32 to monitor log files, so this makes life easier.