I'm using tail -f a.txt
to watch updates on a file called a.txt
.
If I update the file using something like ls -a >> a.txt
in a second virtual console, the changes will display in real-time in the first one.
If I update the file using Vim in a second virtual console, the changes will not display in the first one.
I don't necessarily expect it to trigger an update in that window – but why exactly doesn't this update the terminal running the tail -f
command?
Best Answer
If you edit a file with
vim
, typically it reads the file into memory, then writes a new file. Sotail
is now operating on an out of date copy of the file (which remains in the file system untiltail
(and any other program) stops using it.You can make
tail
follow the filename (rather than the file) by using:Note the upper case
F
.