Display the last part of a file with tail

by
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
, ,

Related posts:

  1. Display the first part of a file with head
  2. Determine file type with the file command
  3. Delete a specific line from a text file with sed
  4. Convert PDF file to text with pdftotext
  5. View the status of a long emerge

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.