On 2022-04-24 03:45, konsolebox wrote:
> A command like this doesn't display data:
> 
> tail -f /var/log/messages -n +1  | grep -e something --line-buffered | tail
> 
> probably because the last tail waits for the pipe to terminate.

Since the data comes from a file, you can use the watch utility for
procps, like this:

  watch "tail -n 50 /var/log/messages | grep -e something"

Unfortunately, that will be blank if the last 50 lines don't
contain any matches.

Workaround:

watch "rm watchfile ;
       tail -n 50 /var/log/messages | grep -e pattern > tmpfile ; 
       if [ -s tmpfile ] ; then mv tmpfile watchfile ; fi ;
       cat watchfile"


Reply via email to