How to 'grep' a continuous stream?

前端 未结 12 1498
清酒与你
清酒与你 2020-11-22 11:15

Is that possible to use grep on a continuous stream?

What I mean is sort of a tail -f command, but with grep on t

12条回答
  •  春和景丽
    2020-11-22 11:34

    If you want to find matches in the entire file (not just the tail), and you want it to sit and wait for any new matches, this works nicely:

    tail -c +0 -f  | grep --line-buffered 
    

    The -c +0 flag says that the output should start 0 bytes (-c) from the beginning (+) of the file.

提交回复
热议问题