Display the last part of a file with tail

by
Ryan
on
October 14, 2008

Similar to the head command which shows you the first few lines of a text file, the tail command lets you to quickly view the last few lines of a text file. It also supports a monitoring mode which displays ongoing changes within the file.

The tail command syntax.

tail [options] file

By default tail will show you the last 10 lines of a text file.

$ tail textfile.txt

You can change the number of lines displayed by adding ‘-n‘ option and adding the number of lines.

$ tail -n 3 textfile.txt

This will show the last 3 lines in the file.

You can keep track of ongoing changes within the file by turning on monitoring mode with the ‘-f‘ option. It is especially helpful when you want to keep an eye on log files.

$ tail -f /var/log/syslog

As lines are appended to the log file they are also displayed by tail.

You can exit the program by pressing Ctrl-C.

No Comments
commands
, ,

No related posts.

Comments (0)

No comments yet

Trackbacks (0)

No trackbacks yet

Leave a Comment

(displayed with your post)
(will not be published)
(optional)
Copyright 2008-2010 WiredRevolution.com. All rights reserved.