Linux Tips: Using ‘tail’ to Display File Updates in Realtime

ruby, php, java, python code

This article will show you how to use the tail command to automatically view data that is appended to a file. This is particularly useful when you want to view the progress of some process from a log file. For example, if you want to see when the Apache server has finished loading, instead of doing a cat on the log file every few seconds you can use the tail command to constantly monitor the log file and output any updates to it.

Using tail to follow a file

To display data that is being appended to a file
tail -f [filename]

Now whenever new data is appended into the file specific, it will be displayed!

One convenient option to use is the -n flag which specifies how many lines of the file to display before it begins following. For example:
tail -f [filename] -n 500

This will output the last 500 files of the file and then begin following it for changes.

See also  How to Append Files in Linux: A Comprehensive Guide

Leave a Comment