[英]Pipe tail output into column
I'm trying to tail a log file and format the output into columns.我正在尝试跟踪日志文件并将 output 格式化为列。 This gives me what I want without tail:这给了我我想要的没有尾巴的东西:
cat /var/log/test.log | column -t -s "|"
How can I pipe the output of tail -f var/log/test.log
into column
?如何将tail -f var/log/test.log
的 pipe output 放入column
?
EDIT: Here's an excerpt from the file.编辑:这是文件的摘录。 I'm manually adding the first line of the file so it could be used as the column headers, but I could format it differently if necessary.我手动添加文件的第一行,以便将其用作列标题,但如有必要,我可以采用不同的格式。
timestamp|type|uri|referer|user_id|link|message
Feb 5 23:58:29 181d5d6339bd drupal_overlake: 1612569509|geocoder|https://overlake.lando/admin/config/development/configuration/config-split/add|https://overlake.lando/admin/config/development/configuration/config-split/add|0||Could not execute query "https://maps.googleapis.com/maps/api/geocode/json?address=L-054%2C%20US&language=®ion=US".
Feb 5 23:58:29 181d5d6339bd drupal_overlake: 1612569509|geocoder|https://overlake.lando/admin/config/development/configuration/config-split/add|https://overlake.lando/admin/config/development/configuration/config-split/add|0||Unable to geocode 'L-054, US'.
You can't do it with the -f
option to tail
.您不能使用tail
的-f
选项来做到这一点。 column
can't produce any output until it receives all its input, since it needs to calculate the number of rows and columns by examining all the input. column
在收到所有输入之前无法生成任何 output,因为它需要通过检查所有输入来计算行数和列数。 tail -f
never stops writing, so column
doesn't know when it's done. tail -f
永远不会停止写入,因此column
不知道何时完成。
You can use您可以使用
tail -n 100 test.log | column -t -s "|"
to format the last 100 lines of the log.格式化日志的最后 100 行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.