grep with continuous pipe does not work

前端 未结 2 951
我寻月下人不归
我寻月下人不归 2021-01-19 07:55

(maybe it is the \"tcpflow\" problem)

I write a script to monitoring http traffic, and I install tcpflow, then grep

it works (a

2条回答
  •  遇见更好的自我
    2021-01-19 08:40

    To grep a continuous stream use --line-buffered option:

    sudo tcpflow -p -c -i eth0 port 80 2> /dev/null | grep --line-buffered '^Host'
    

    --line-buffered

    Use line buffering on output. This can cause a performance penalty.


    Some reflections about buffered outputting(stdbuf tool is also mentioned):

    Pipes, how do data flow in a pipeline?

提交回复
热议问题