How to 'grep' a continuous stream?

前端 未结 12 1554
清酒与你
清酒与你 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:37

    Use awk(another great bash utility) instead of grep where you dont have the line buffered option! It will continuously stream your data from tail.

    this is how you use grep

    tail -f  | grep pattern
    

    This is how you would use awk

    tail -f  | awk '/pattern/{print $0}'
    

提交回复
热议问题