How to 'grep' a continuous stream?

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

    In most cases, you can tail -f /var/log/some.log |grep foo and it will work just fine.

    If you need to use multiple greps on a running log file and you find that you get no output, you may need to stick the --line-buffered switch into your middle grep(s), like so:

    tail -f /var/log/some.log | grep --line-buffered foo | grep bar
    

提交回复
热议问题