Last month in Toolbox, we examined how the ubiquitous grep program can help you ferret out information from your log files or other text-based files (see "Toolbox: Grep," August 2005, InstantDoc ID 46869). As I mention in that article, another useful UNIX tool that's worthy of inclusion in your Windows toolbox is the tail program. In essence, tail displays the last few lines of a text fileespecially helpful when you're examining log files. For example, suppose you're programming new rules for your firewall. You can use tail on your log file to see the rules' effect.
Tail is available on most UNIX systems, or you can download a GNU-licensed Win32 version from the Sourceforge Web site (http://unxutils.sourceforge.net). Download the UnxUpdates.zip file, then extract tail.exe to your computer.
Using Tail Alone
Used alone, tail displays the last few lines of a text file. The utility also supports several parameters that you can use to customize how it displays information. One particularly useful option is the follow (-f) parameter, which you can use to continuously watch for and display changes to a text file. For example, the command
tail -f ex050410.log
will display the last 10 lines of the log file named ex050410.log and will monitor the file and display new entries as they're added. If the file is a Microsoft IIS Web service log and someone accesses the Web site, IIS will write out a new log record. The new additions will immediately show up in the console that's running tail. This parameter eases troubleshooting by letting you immediately see new entries. . . .