解析上一条命令的时间数据,该命令的最后一列总共花费了“00:00”的时间

解析上一条命令的时间数据,该命令的最后一列总共花费了“00:00”的时间

我有上一个命令输出,用于将数百台服务器收集到文件中,现在的问题是输出是“Feb,Jan,Feb”,这意味着它还采用了去年的 Feb 输出,因此,我正在寻找是否可以获得每个服务器名称为“Feb to Jan”的输出,如果它再次返回 Feb,则忽略它,因为它将用于过去的一年(在我的情况下是 2016 年),而我只查找 2017 年。因为考虑到上述事实,我正在查找是否有任何服务器在最后一列中具有时间“(00:00)”,用于“Feb to Jan”之间的整个时间段。

以下是数据格式,请提供您的解决方案。我标记了 awk、sed、shell,因为任何解决方案都适用于我。

[oraprod8] out: root     pts/0        oratest.paden Thu Feb 16 16:12 - 16:12  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Wed Feb 15 03:28 - 03:28  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Wed Feb 15 03:27 - 03:27  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Wed Feb 15 03:27 - 03:27  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Mon Feb  6 18:36 - 18:36  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Sun Feb  5 07:26 - 07:26  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Sun Feb  5 07:26 - 07:26  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Sun Feb  5 07:26 - 07:26  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Sat Jan 28 04:16 - 04:16  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Thu Jan 26 17:03 - 17:03  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Thu Jan 26 17:03 - 17:03  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Thu Jan 26 17:03 - 17:03  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Wed Jan 18 08:07 - 08:07  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Mon Jan 16 21:13 - 21:13  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Mon Jan 16 21:13 - 21:13  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Mon Jan 16 21:13 - 21:13  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Sun Jan  8 18:33 - 18:33  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Sat Jan  7 06:56 - 06:56  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Sat Jan  7 06:56 - 06:56  (00:00)
[oraprod8] out: root     pts/0        oratest.paden Sat Jan  7 06:56 - 06:56  (00:00)
[oraprod8] out: root     pts/0        dbtest.pad Thu Feb 11 13:58 - 13:58  (00:00)
[oraprod8] out: root     pts/0        dbtest.pad Thu Feb 11 13:58 - 13:58  (00:00)
[oraprod8] out: root     pts/0        dbtest.pad Thu Feb 11 13:58 - 13:58  (00:00)
[oraprod8] out: root     pts/0        dbtest.pad Thu Feb 11 13:58 - 13:58  (00:00)
[oraprod8] out: rocky pts/0        sojourner.padenc Fri Feb  5 09:08 - 11:08  (02:00)
[oraprod8] out: rocky pts/0        vlsj-rocky.pa Wed Feb  3 09:48 - 10:03  (00:14)
[oraprod8] out: rocky tty1                          Wed Feb  3 09:31 - 09:31  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Thu Feb 16 16:12 - 16:12  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Wed Feb 15 03:28 - 03:28  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Wed Feb 15 03:27 - 03:27  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Wed Feb 15 03:27 - 03:27  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Mon Feb  6 18:36 - 18:36  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Sun Feb  5 07:26 - 07:26  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Sun Feb  5 07:26 - 07:26  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Sun Feb  5 07:26 - 07:26  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Sat Jan 28 04:16 - 04:16  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Thu Jan 26 17:03 - 17:03  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Thu Jan 26 17:03 - 17:03  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Thu Jan 26 17:03 - 17:03  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Wed Jan 18 08:07 - 08:07  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Mon Jan 16 21:13 - 21:13  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Mon Jan 16 21:13 - 21:13  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Mon Jan 16 21:13 - 21:13  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Sun Jan  8 18:33 - 18:33  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Sat Jan  7 06:56 - 06:56  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Sat Jan  7 06:56 - 06:56  (00:00)
[oraprod7] out: root     pts/0        oratest.paden Sat Jan  7 06:56 - 06:56  (00:00)
[oraprod7] out: root     pts/0        dbtest.pad Thu Feb 11 13:58 - 13:58  (00:00)
[oraprod7] out: root     pts/0        dbtest.pad Thu Feb 11 13:58 - 13:58  (00:00)
[oraprod7] out: root     pts/0        dbtest.pad Thu Feb 11 13:58 - 13:58  (00:00)
[oraprod7] out: root     pts/0        dbtest.pad Thu Feb 11 13:58 - 13:58  (00:00)
[oraprod7] out: rocky pts/0        sojourner.padenc Fri Feb  5 09:08 - 11:08  (02:00)
[oraprod7] out: rocky pts/0        vlsj-rocky.pa Wed Feb  3 09:48 - 10:03  (00:14)
[oraprod7] out: rocky tty1                          Wed Feb  3 09:31 - 09:31  (00:00)

答案1

管理即服务 (RMaaS):man last

-F

打印满的登录和注销的时间和日期。

然后过滤掉不理想的年份......

last -F |grep " Feb " |grep -v " 2016 " 
herman   pts/0        52d94b85.cm-11   Tue Feb 21 15:15:13 2017   still logged in
herman   pts/0        52d94b85.cm-11   Mon Feb 20 14:24:10 2017 - Mon Feb 20 16:44:41 2017  (02:20)
herman   pts/0        52d94b85.cm-11   Sat Feb 18 14:12:36 2017 - Sat Feb 18 20:57:21 2017  (06:44)
herman   pts/0        52d94b85.cm-11   Wed Feb 15 11:20:45 2017 - Wed Feb 15 11:34:03 2017  (00:13)
herman   pts/0        52d94b85.cm-11   Tue Feb 14 13:26:28 2017 - Tue Feb 14 15:55:37 2017  (02:29)
herman   pts/0        52d94b85.cm-11   Mon Feb 13 13:07:59 2017 - Mon Feb 13 16:13:55 2017  (03:05)
....
herman   pts/0        d64-180-204-13   Sat Feb 23 17:54:16 2013 - Sat Feb 23 20:26:42 2013  (02:32)
herman   pts/0        d64-180-204-13   Wed Feb 20 04:49:02 2013 - Wed Feb 20 05:07:50 2013  (00:18)
herman   pts/0        d64-180-204-13   Thu Feb 14 09:05:39 2013 - Thu Feb 14 12:29:51 2013  (03:24)
herman   pts/0        d64-180-196-15   Sun Feb  3 17:36:00 2013 - Sun Feb  3 20:47:08 2013  (03:11)

相关内容