[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: |
Rob Landley |
Subject: |
Re: Allow tail to display data after stream stops sending input after N seconds |
Date: |
Sun, 24 Apr 2022 17:50:03 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 |
On 4/24/22 05: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.
>
> But this could work if there exists an option like -S which allows
> tail to wait for N seconds before considering input as "stopped" and
> then displaying currently absorbed input.
>
> Current workaround would be to use a temporary file and use sleep or
> maybe some repeated inotify checks before running second tail but it's
> messy.
No, current workaround would be an interposer in the pipeline:
unset X; { echo hello; sleep 3; echo hello;} | \
while read $X i; do echo $i; X="-t 1"; done | tail
Needs to be slightly fancier to _exit_ promptly (since the generator process
that won't notice sigpipe until it tries to write again that thus doesn't exit
keeping the pipeline alive despite every process after it having exited), but it
would at least produce the output promptly.
Rob
Re: Allow tail to display data after stream stops sending input after N seconds, Kaz Kylheku, 2022/04/26
Re: Allow tail to display data after stream stops sending input after N seconds, Kaz Kylheku, 2022/04/27