Alternative for "tail -f" that follows filename
Some implementations of tail
have an option for this; here's the description from the man page for GNU tail:
-F
same as--follow=name --retry
-f
,--follow
[=
{name|descriptor}]
output appended data as the file grows;-f
,--follow
, and--follow=descriptor
are equivalent
--retry
keep trying to open a file even when it is or becomes inaccessible; useful when following by name, i.e., with--follow=name
As this option isn't specified by POSIX, you can't depend on it everywhere. Some known implementations:
- GNU - has
-F
as described above - Mac OS X, FreeBSD and NetBSD - have a similar
-F
option with the same effect - OpenBSD -
-f
is enough (if the file is replaced (i.e., the inode number changes), tail will reopen the file and continue) - Solaris - no equivalent
- Busybox -
-F
is available in recent versions, but must be compiled withENABLE_FEATURE_FANCY_TAIL
(it's not compiled-in by default)
Alternative is tail -F
command.
The -F
option implies --follow=name
with --retry
option, so tail is watching your file even if it has been deleted and created again.
Since you have asked for alternative:
The less
utility could be an alternative for tail -F
.
It will have to be run as follows: less --follow-name filename.log
and press Shift + F.
This will give you same results as tail -F
.