Is there a command/program for OS X that allows me to hook to a file and display its changes in realtime without re-opening it, much like "top" monitors system processes in realtime?
Asked
Active
Viewed 3,346 times
3 Answers
7
You can use tail
to monitor single log file.
If file is deleted, then created again you may want to use tail -F
to actively monitor file changes
If same file is being appended too use tail -f
to actively monitor file changes

Hrvoje Špoljar
- 5,245
- 26
- 42

gelraen
- 2,341
- 20
- 19
-
1It doesn't seem to display changes as the file updates – Mark Feb 06 '11 at 18:38
-
It does, at least on FreeBSD and linuxes. Should work on Mac OS X too. – gelraen Feb 06 '11 at 18:41
-
@Mark how do you modify the file during checking? – ulidtko Feb 06 '11 at 18:48
-
Perhaps it has something to do with the fact that the file is in a Dropbox and is updated perhaps a bit differently? – Mark Feb 06 '11 at 18:48
-
It does work on OS X. On my systems anyway. – Sven Feb 06 '11 at 18:50
-
2Try `tail -F`. Consult with `man tail` for more details about these options. – gelraen Feb 06 '11 at 18:51
-
It also works on a Dropbox folder. – Sven Feb 06 '11 at 18:53
-
-F instead of -f did it, thank you! – Mark Feb 06 '11 at 18:55
-
`multitail` can monitor multiple files. – Dennis Williamson Feb 06 '11 at 19:51
1
If you are doing this on file sync'd by dropbox the chances are it is creating a new file with a different inode so the tail -f command and the less +F command do not work since they are still referencing the old file handle they opened initially.
I suggest trying
watch "tail /path/to/filename"
It feels hackish but at least every X seconds it will re run tail on the filename giving you the updated output regardless of whether or not the inodes change on the file.

ScottZ
- 467
- 2
- 7