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

By : Reddy
Source: Stackoverflow.com
Question!

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

By : Reddy


Answers

Did you put the file name after the



thanks for your help.

here is my code to insert into mysql with the word "error":

tail -f /var/log/httpd/error_log | \
grep -E --line-buffered "error" | \
while read line; do \
#echo -e "MY LINE: ${line}"; done
echo "INSERT INTO logs (logid,date,log) VALUES (NULL, NOW(), '${line}');" | mysql -uUSERDB -pPASSDB DBNAME; done


This video can help you solving your question :)
By: admin