Matthieu Napoli Matthieu Napoli - 1 year ago 90
Bash Question

How to 'grep' a continuous stream?

Is that possible to use

on a continuous stream?

What I mean is sort of a
tail -f <file>
command, but with
on the output in order to keep only the lines that interest me.

I've tried
tail -f <file> | grep pattern
but it seems that
can only be executed once
finishes, that is to say never.

tad tad
Answer Source

Turn on grep's line buffering mode.

tail -f file | grep --line-buffered my_pattern