Linux awk 查找日志中某个字段长度最大的记录

mac2024-03-24  27

1.查找日志中某个字段长度最大的记录

假设日志名为:chat.log 日志格式为: |时间|地点|…|消息|字段N|

假设第23个字段消息是我们想要比较的字段。 通过以下命令筛选:

cat chat.log | awk -F '|' '{if(length($23)>maxlength{ maxlength=length($23);t=$0}};END{print t}'
最新回复(0)