执行 a 时tail -f error.log,如何在 3 秒内未向文件附加任何内容后以编程方式插入换行符?
(显然,一旦添加了一个换行符,在将另一行文本添加到日志文件之前,不应添加其他换行符)
例如,这些行被附加到 error.log :
foo
bar
boo [[wait 4 seconds]]
2far
2foo
2bar
2boo [[wait 40 seconds]]
2far
Run Code Online (Sandbox Code Playgroud)
这将是控制台中的输出:
foo
bar
boo
2far
2foo
2bar
2boo
2far
Run Code Online (Sandbox Code Playgroud)