Windows tail command line options

by admin on August 15, 2009

Unix/Linux operating systems have tail command which can be used to print the specified number of lines from the end of a text file. We have an equivalent command in Windows  also but it is not available with the default OS. We can download it as part of Windows server 2003 resource kit tools(link is given below). It works on Windows XP too.

Download Windows Server 2003 Resource Kit

Syntax of this windows tail command is same as it’s Linux counterpart.

tail [-f] [-n] filename

n is the number of lines to be printed from the end. If unspecified it prints the last 10 lines.
-f : print the new lines as and when added.

examples:
1) Print the last 4 lines from the file data.txt

tail -4 data.txt

2)Print the contents of the file file1.txt and keep checking for the new lines added.

tail -f file1.txt

{ 1 comment… read it below or add one }

René Ernst October 15, 2011 at 10:42 am

Combination of -n and -f is not possible

E.g. tail -1000 -f log.txt

current behaviour: displays the last 1000 lines then stops
desired behaviour: displays the last 1000 lines of log.txt and then keeps checking for lines being added

Reply

Leave a Comment

Previous post:

Next post: