I have been able to get all login logs in the system for Wednesday. But I am unable to get the first and last login of each day on which it is Wednesday.
Progress so far – `last | grep ‘^[^reboot].*Wed’
Through the above I am achieving this:-
cent pts/0 :0 Wed Mar 11 11:57 - 11:41 (19+23:44)
cent pts/0 :0 Wed Mar 4 11:10 - 11:57 (7+00:46)
cent :0 :0 Wed Mar 4 11:10 - 11:42 (27+00:31)
cent pts/0 :0 Wed Jan 22 11:27 - crash (4+10:10)
cent :0 :0 Wed Jan 22 11:27 - crash (4+10:10
cent pts/0 :0 Wed Jan 22 11:12 - 11:21 (00:09)
cent pts/0 :0 Wed Jan 8 11:22 - 11:54 (12+00:32)
cent :0 :0 Wed Jan 8 11:21 - down (14+00:00)
But the expected output should be this:-
cent pts/0 :0 Wed Mar 11 11:57 - 11:41 (19+23:44)
cent pts/0 :0 Wed Mar 4 11:10 - 11:57 (7+00:46)
cent :0 :0 Wed Mar 4 11:10 - 11:42 (27+00:31)
cent pts/0 :0 Wed Jan 22 11:27 - crash (4+10:10)
//Second entry omitted as we are supposed to only display first and last
//login each day
cent pts/0 :0 Wed Jan 22 11:12 - 11:21 (00:09)
cent pts/0 :0 Wed Jan 8 11:22 - 11:54 (12+00:32)
cent :0 :0 Wed Jan 8 11:21 - down (14+00:00)
2
Answers
You can do it with a simple
awk
script:You can now test it:
Try this: