在查看长行时,会发生自动换行。但是,在查看日志文件时,需要清晰地看到每一行的开头和结尾。因此,在使用 tail 命令查看日志时,如何添加缩进呢?可以将自动换行从第 10 列开始,而不是从第 0 列开始。例如:
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.
请注意,我并不是尝试修改行保存到日志文件的方式,而只是使用不同的格式显示该行。
cat
命令有-n
和-E
选项,可以在某些情况下提高可读性。虽然不完全符合要求,但仍然很有用。 - keltar