打印最新同一时间的日志信息
2016-04-25 14:23
253 查看
有如下的日志/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)将这一段打印出来,命令精简越好。
grep "`grep [^0-9] /var/log/message.log |cut -d , -f 1|uniq|tail -1`" /var/log/message.log grep "`grep [^0-9] /var/log/message.log |awk -F ',' '{print $1}'|uniq |tail -1`" /var/log/message.log grep "`tail -1 /var/log/message.log |awk -F ',' '{print $1}'`" /var/log/message.log
我感觉写的好臃肿,但是目前是实现了。在改进吧。
相关文章推荐
- cut命令
- 文本处理工具AWK详解
- awk简介与学习笔记收集第1/3页
- awk 九九乘法表 shell实现代码
- linux shell awk获得外部变量(变量传值)简介
- sed或awk处理文件最后一行的实现方法
- awk中查看包含某两列字符的用法
- awk区间取值的例子
- awk实现Left、join查询、去除重复值以及局部变量讲解例子
- awk中让人郁闷的system()函数
- awk中实现ord函数功能
- awk中RS、ORS、FS、OFS的区别和联系小结
- 分享awk变量$0的妙用
- linux awk时间计算脚本及awk命令详解
- awk正则表达式和内置函数的使用方法实例详解
- Shell正则表达式之grep、sed、awk实操笔记
- Linux里awk中split函数的用法小结
- Shell对比两个文件中的记录有多少重复
- awk学习系列-第3/3部分
- grep,awk,sed实例