TrumanWong

tailf

Displays the last few lines of the specified file on the screen, usually used for trace output of log files.

Supplementary instructions

The tailf command is almost identical to tail -f, strictly speaking it should be more similar to tail --follow=name. It can also continue to track when the file is renamed, which is especially suitable for following the growth of a log file. Unlike tail -f, it will not access the disk file if the file is not growing. tailf is particularly suitable for tracking log files on portable computers because it saves power and reduces disk access. The tailf command is not a script, but a binary executable file compiled with C code. Some Linux installations do not have this command.

The difference between tailf and tail -f

  1. tailf always reads bit by bit from the beginning of the file, while tail -f starts reading from the end of the file.
  2. When tailf checks the file growth, it uses the file name and uses the stat system call; tail -f uses the opened file descriptor; Note: tail can also achieve similar effects of tracking file names; but tail Always use the fstat system call instead of the stat system call; the result is: by default, when tail's files are secretly deleted, tail does not know, but tailf does.

grammar

tailf logfile # Dynamically track the log file logfile, initially printing the last 10 lines of the file.

Options

-n, --lines NUMBER # Output the last number of lines
-NUMBER # Same as NUMBER `-n NUMBER'
-V, --version # Output version information and exit
-h, --help # Show help and exit

Parameters

Target: Specify the target log.

Example

tailf log/WEB.LOG
tailf -n 5 log2014.log # Display the last 5 lines of the file