简体   繁体   English

如何将函数应用于tail -f的输出?

[英]How to apply a function to the output of tail -f?

I have a log file that continuously gets updated.我有一个不断更新的日志文件。 I can view the file with tail -f and see all the changes as they come in. However, there is an issue - the text contains the characters \\n instead of newlines.我可以使用tail -f查看文件并查看所有更改。但是,存在一个问题 - 文本包含字符 \\n 而不是换行符。 I would like to change the characters \\n into actual newlines.我想将字符 \\n 更改为实际的换行符。 How do I go about doing that?我该怎么做?

Found a solution that works for me:找到了一个适合我的解决方案:

tail -f logfile | sed 's/\\n/\
/g'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM