6

I don't understand the function of the option -f added to the tail command.

I know that tail views the "last" part of a file. The manual says that

-f outputs appended data as the file grows

But I don't really understand what that means. I know the meaning of each word in the previous quotation, but I don't understand the meaning of the whole sentence.

polym
  • 10,852

3 Answers3

7

It means tail -f command will wait for new strings in the file and show these strings dynamically. This command useful for observing log files .

For example try, tail -f /var/log/messages.

TPS
  • 2,481
svq
  • 1,000
4

You can think of -f as "follow". When -f is added to tail, the command will not exit but waits to see if more is added to the file; that additional text will be printed by tail. You normally kill a tail -f with ^c.

It is often used with log files that that are being written by daemons or a background user process.

tail -f /var/log/syslog

wmills
  • 61
3

If you have an active log file,program is running while writing info to log file. you can open the log with tail -f so the log is being displayed "live". tail -f /var/log/logfile is like constanly doing tail /var/log/logfile

Stapper
  • 91