当您在长线上做尾巴时,会发生缠绕。但是,当您拖尾日志时,重要的是要看到一行结束而另一行开始。那么,是否有可能在尾部创建一个标识?包装而不是从第0列开始,将从第10列开始。例如:
this is a very long line to simulate how a line would wrap in a terminal window
suppose this is the wrapping and it is just the same line the continues here.
this is another very long line to simulate how a line would wrap in a terminal window
suppose this is the wrapping and it is just the same line the continues here.
与
this is a very long line to simulate how a line would wrap in a terminal window
suppose this is the wrapping and it is just the same line the continues here.
this is another very long line to simulate how a line would wrap in a terminal window
suppose this is the wrapping and it is just the same line the continues here.
请注意,我不是要修改行保存到日志文件的方式,而是仅使用不同的格式显示行。
答案 0 :(得分:7)
将管尾拖到您选择的格式化程序中。一个简单的perl脚本应该可以工作:
tail log-file | perl -pe 's/(.{80})/$1\n\t/g'
将使用制表符缩进行。如果您正在执行tail -f
,您可能希望通过以下方式最小化缓冲:
tail -f log-file | perl -pe '$|=1; s/(.{80})/$1\n\t/g'
答案 1 :(得分:2)
如果:
fmt
(Linux)尝试,例如:
tail -f log | fmt -t
-w
;例如:-w 80
fmt
不会在单词中间分开,这有助于提高可读性。不幸的是,如果没有空格或标签,它根本就不会分裂。