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