Piping tail output though grep twice

前端 未结 2 1268
闹比i
闹比i 2020-11-27 18:04

Going with a typical Apache access log, you can run:

tail -f access_log | grep \"127.0.0.1\"

Which will only show you the logs (as they are

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 18:30

    This is the result of buffering, it will eventually print when enough data is available.

    Use the --line-buffered option as suggested by Shawn Chin or if stdbuf is available you can get the same effect with:

    tail -f access_log | stdbuf -oL grep "127.0.0.1" | grep -v ".css"
    

提交回复
热议问题