从 tail -f 输出管道到 grep 后写入文件 [英] write to a file after piping output from tail -f through to grep

查看:28
本文介绍了从 tail -f 输出管道到 grep 后写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在将 tail -f 的输出通过管道传输到 grep 后写入文件.比如说,将 error_log "FreeSwitch.log" 中带有 "Playing:" 的所有行写入文件 "temp".

I'm looking to write to a file after piping output from tail -f through to grep. Say,write to a file "temp" for all lines with "Playing:" within in error_log "FreeSwitch.log".

 tail -f "/var/lof/freeswitch/freeswitch.log" | grep "Playing:" > temp

但不工作!这是一个centos 5.5

but not working ! It is a centos 5.5

推荐答案

也许您有缓冲问题?请参阅BashFAQ:什么是缓冲?

Maybe you have an issue with buffering? See BashFAQ: What is buffering?

你可以例如试试:

tail -f /var/lof/freeswitch/freeswitch.log | grep --line-buffered "Playing:" > temp

这篇关于从 tail -f 输出管道到 grep 后写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆