更新时间:2023-12-04 12:13:58
我相信这里的问题是第一个 grep 正在缓冲输出,这意味着第二个 grep 在缓冲区被刷新之前不会看到它.
I believe the problem here is that the first grep is buffering the output which means the second grep won't see it until the buffer is flushed.
尝试在您的第一个 grep 中添加 --line-buffered
选项:
Try adding the --line-buffered
option on your first grep:
tail -f access_log | grep --line-buffered "127.0.0.1" | grep -v ".css"
有关详细信息,请参阅 "BashFAQ/009 -- 什么是缓冲?或者,为什么我的命令行没有输出:tail -f logfile | grep 'foo bar' | awk ...
"
For more info, see "BashFAQ/009 -- What is buffering? Or, why does my command line produce no output: tail -f logfile | grep 'foo bar' | awk ...
"