UNIX Tip of the Week

Watch a file grow before your very eyes!


Most of us have used the tail command to view the last ten lines of a file.
The tail command has a -f option that may be used to watch a file grow dynamically.

Consider a process that periodically appends text to a file (perhaps to log its progress).
tail -f filename displays the last ten lines of the file, then continues to display new lines as they are appended.

The -f option causes tail to never terminate; you'll not see your shell prompt again until you kill the process with ^C.

Your clever systems manager frequently uses this to observe log files. Did an X-terminal really boot properly, receiving its correct configuration file? Starting tail -f on the system's daemon log file, then booting the X-terminal reveals all the details of the boot process, as they occur.

A useful mnemonic might be to think of it as the "-forever" option.
Try man tail if you think of it. The -r option is interesting, too!


Revised: February 11, 2000