i'm trying to build a shell script to monitor some log files. I'm using a command like this:
tail -f /var/somelog | grep --line-buffered " some test and p l a c e h o l d e r" | cut -f 3,4,14 -d " "
the log file is like:
some test and p l a c e h o l d e r 3
some test and p l a c e h o l d e r 4
some test and p l a c e h o l d e r 5
some test and p l a c e h o l d e r 6
and so on.. My issue is that the output of the command does not display the last line
some test and p l a c e h o l d e r 6
until line
some test and p l a c e h o l d e r 7
is added to the log.
I hope I made clear my issue. Can anyone help me to solve this? Thank you :)
od -c /var/somelog
.tail -f
? If that is the case then @David has pointed out it correctly.tail -f
, and even withtail -f | grep --line-buffered "pattern"
, but you will lose the last line once you introduce cut into the pipeline.