I'm working with a logfile with the following format:
Oct 12 01:28:26 server program: 192.168.1.105 more text herefor 1.105
Oct 12 01:30:00 server program: 192.168.1.104 more text herefor 1.104
Oct 12 01:30:23 server program: 192.168.1.103 more text herefor 1.103
Oct 12 01:32:39 server program: 192.168.1.101 more text herefor 1.101
Oct 12 02:28:26 server program: 192.168.1.105 more text herefor 1.105
Oct 12 02:30:00 server program: 192.168.1.104 more text herefor 1.104
Oct 12 02:30:23 server program: 192.168.1.103 more text herefor 1.103
Oct 12 02:32:39 server program: 192.168.1.101 more text herefor 1.101
I need to achieve this:
Oct 12 02:28:26 server program: 192.168.1.105 more text herefor 1.105
Oct 12 02:30:00 server program: 192.168.1.104 more text herefor 1.104
Oct 12 02:30:23 server program: 192.168.1.103 more text herefor 1.103
Oct 12 02:32:39 server program: 192.168.1.101 more text herefor 1.101
How can I send the new output to a file? I have tried this:
awk '!_[$6]++ {a=$6} END{print a}' logfile
But it does not give me the results expected. How can I use awk or sed to give me only the unique lines with last time the string match was seen or based on date/time?