我希望在将 tail -f 的输出通过管道传输到 grep 后写入文件。 比如说,将错误日志“FreeSwitch.log”中包含“Playing:”的所有行写入文件“temp”。
tail -f "/var/lof/freeswitch/freeswitch.log" | grep "Playing:" > temp
但不工作!这是centos 5.5
最佳答案
也许您遇到缓冲问题?参见 BashFAQ: What is buffering ?
例如,您可以尝试:
tail -f /var/lof/freeswitch/freeswitch.log | grep --line-buffered "Playing:" > temp
关于linux - 在将 tail -f 的输出通过管道传输到 grep 后写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5341297/