打印出最新同一时间的日志信息

回复 收藏
本帖最后由 balich 于 2016-4-25 14:32 编辑

有如下的日志/var/log/message.log,要求把最新时间的日志打印出来。

Time,Entity,Severity,Node,Desc
00:00:01 04/25/2016 ,Node,Info,0,IMG Control Link is Up
00:00:01 04/25/2016 ,Node,Info,0,HostAlarm(Software License Verified)
00:00:01 04/25/2016 ,Node,Info,0,HostAlarm(Software Versions Matched)
11:16:45 04/25/2016 ,Node,Info,0,IMG Control Link is Up
11:16:45 04/25/2016 ,Node,Info,0,HostAlarm(Software License Verified)
11:16:45 04/25/2016 ,Node,Info,0,HostAlarm(Software Versions Matched)
12:11:46 04/25/2016 ,Node,Info,0,IMG Control Link is Up
12:11:46 04/25/2016 ,Node,Info,0,HostAlarm(Software License Verified)
12:11:46 04/25/2016 ,Node,Info,0,HostAlarm(Software Versions Matched)


比如,这里最新时间的日志应该是:
12:11:46 04/25/2016 ,Node,Info,0,IMG Control Link is Up
12:11:46 04/25/2016 ,Node,Info,0,HostAlarm(Software License Verified)
12:11:46 04/25/2016 ,Node,Info,0,HostAlarm(Software Versions Matched)

将这一段打印出来,命令精简越好。





{{{密码回复可见}}}

我写的有点臃肿,大伙试一试,有没有更加精简的。

2016-04-25 14:29 举报
已邀请:
0

maria

赞同来自:

tail -f /var/log/message.log
打印message.log的最后10行,并动态显示之后的日志信息
0

balich

赞同来自:

maria 发表于 2016-4-25 14:34
tail -f /var/log/message.log
打印message.log的最后10行,并动态显示之后的日志信息

tail -f 这个我知道。这是要单独取出最新同一时间的日志。
0

m.chang

赞同来自:

just look.
0

阿杰

赞同来自:

1111
0

clq56688

赞同来自:

{:4_91:}
0

daydayup

赞同来自:

看看

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: