EXPLAIN: The GNU/Linux ‘Tail’ Command.

Much like the head command will display the top n number of lines of a specified file, the tail command will display the bottom n number of lines from a specified file.
For example, to see the last 10 lines of my /var/messages file, I can type:
tail /var/messages
the default is 10 lines, but if I wanted to see the last 50 lines, I could type:
tail -50 /var/messages
Unlike the head command, the tail command has a very useful switch. Putting the -f switch after the command will cause tail to go into monitoring mode and continue to output the last n number of lines as the specified file changes.
This is very useful for monitoring your system log files as they change in real time. For example, to monitor the last 10 lines of your system log in a terminal window, become root and type:
tail -f /var/log/syslog
To exit monitoring mode, hit Ctrl-Z.
Related Stories
POSTED IN: Explanation
1 opinion for EXPLAIN: The GNU/Linux ‘Tail’ Command.
New Linux User » EXPLAIN: The GNU/Linux ‘Head’ Command.
Nov 28, 2005 at 7:49 am
[…] I have frequently used the tail command, but wasn’t ware that there was a complimentary head command. The head command will display the first n number of lines from a specified text file. For example, to view the first 10 lines of my /var/messages file, I can type: head /var/messages […]
Have an opinion? Leave a comment: