coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Allow tail to display data after stream stops sending input after N


From: Kaz Kylheku
Subject: Re: Allow tail to display data after stream stops sending input after N seconds
Date: Tue, 26 Apr 2022 10:12:40 -0700
User-agent: Roundcube Webmail/1.4.13

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

[Prev in Thread] Current Thread [Next in Thread]