[英]using Sed with grep for the log file
每当我执行 error_log($ex->getTraceAsString()) 时,我都试图使 php 错误日志明显好,但它打印了 \n 所以我想出了可能性,结果证明我应该从终端本身做到这一点
所以我做
tail -f /var/log/apache2/error.log | sed 's/\\n/\n/g'
但以前我曾经为我的日志做过
tail -f /var/log/apache2/error.log | grep production
对于包含关键字 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
(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
但这些都不起作用。 我应该怎么办?
使用 /..../ 等将搜索字符串添加到 sed 语句:
tail -f /var/log/apache2/error.log | sed -n '/production/s/\\n/\n/gp'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.