write to a file after piping output from tail -f through to grep

Reddy picture Reddy · Mar 17, 2011 · Viewed 12.2k times · Source

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

but not working ! It is a centos 5.5

Answer

bmk picture bmk · Mar 17, 2011

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

You could e.g. try:

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