[英]Modifying `tail -f` output in real time
The logs for my work are output with a | 我的工作日志输出为| instead of a newline, making them incredibly difficult to read.
而不是新行,使他们难以阅读。 What I do now is copy and paste them into vim and run
:%s/|/\\r/g
to replace all pipe's with a new line. 我现在做的是将它们复制并粘贴到vim中并运行
:%s/|/\\r/g
以用新行替换所有管道。
I'd love to be able to do this in real time in the tail -f
output of the logs. 我希望能够在日志的
tail -f
输出中实时执行此操作。 So instead of having to copy and paste it (or run sed
on the log file), I could just read the logs right away as they are written to the file, with the pipe separator replaced with new lines. 因此,不必复制和粘贴它(或在日志文件上运行
sed
),我可以立即读取日志,因为它们被写入文件,管道分隔符替换为新行。
Is there a way to do this? 有没有办法做到这一点? (I can't modify the line separator for the log output)
(我无法修改日志输出的行分隔符)
您可以将tail -f
输出管道传输到sed
并运行与vim
一起运行的相同正则表达式(转义已添加):
tail -f file | sed -e s/\|/\\n/g -
I think 我认为
tail -f <log file> | tr \| \n | less
or some such might work. 或某些可能的工作。 Might take some fiddling.
可能需要一些摆弄。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.