[英]using Sed with grep for the log file
I was trying to make php error logs visibly good whenever I do error_log($ex->getTraceAsString()) but it printed \n so I figured out the possibilities, it turned out that I should do that from terminal itself每当我执行 error_log($ex->getTraceAsString()) 时,我都试图使 php 错误日志明显好,但它打印了 \n 所以我想出了可能性,结果证明我应该从终端本身做到这一点
so I do所以我做
tail -f /var/log/apache2/error.log | sed 's/\\n/\n/g'
But Previously for my logs I used to do但以前我曾经为我的日志做过
tail -f /var/log/apache2/error.log | grep production
for logs that contains the keyword production对于包含关键字 production 的日志
But I want both of them what should I do?.So that my both criteria worked但我想要他们两个我应该怎么做?所以我的两个标准都有效
I tried我试过
tail -f /var/log/apache2/error.log | grep production | sed 's/\\n/\n/g'
tail -f /var/log/apache2/error.log | sed 's/\\n/\n/g' | grep production
(tail -f /var/log/apache2/error.log | grep production) | sed 's/\\n/\n/g'
(tail -f /var/log/apache2/error.log | sed 's/\\n/\n/g') | grep production
But none of these worked.但这些都不起作用。 What should I do?
我应该怎么办?
Add the search string to the sed statement with /..../ and so:使用 /..../ 等将搜索字符串添加到 sed 语句:
tail -f /var/log/apache2/error.log | sed -n '/production/s/\\n/\n/gp'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.