How does the "tail" command's "-f" parameter work?

From the tail(1) man page:

   With  --follow  (-f),  tail  defaults to following the file descriptor,
   which means that even if a tail’ed file is renamed, tail will  continue
   to  track  its  end.   This  default behavior is not desirable when you
   really want to track the actual name of the file, not the file descrip-
   tor (e.g., log rotation).  Use --follow=name in that case.  That causes
   tail to track the named file  in  a  way  that  accommodates  renaming,
   removal and creation.

Your text editor is renaming or deleting the original file and saving the new file under the same filename. Use -F instead.


Your editor has its own buffer for the file. When you modify the text in the editor, nothing is written to the file itself.

When you save your changes, chances are that the editor simply deletes the old file and create a new one. tail -f will still be connected to the deleted file, so it won't show anything new.


tail "refresh" each 1 second by default, not realtime.

Try with this (you need bash4):

  • Open 2 terminals.
  • In the first terminal execute touch ~/output.txt and tail -f ~/output.txt.
  • In the second terminal execute for i in {0..100}; do sleep 2; echo $i >> ~/output.txt ; done
  • Look at the output of tail in the first terminal.