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

前端 未结 4 613
孤独总比滥情好
孤独总比滥情好 2021-01-05 15:19

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 \"FreeSwit

4条回答
  •  悲&欢浪女
    2021-01-05 16:06

    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
    

提交回复
热议问题