Remove lines, Sorted with Time based columns using AWK & SORT

Hi

having a file as follows

MediaErr.log

84   Server1     Policy1       Schedule1 master1   05/08/2008 02:12:16
84   Server1     Policy1       Schedule1 master1   05/08/2008 02:22:47
84   Server1     Policy1       Schedule1 master1   05/08/2008 03:41:26
84   Server1     Policy1       Schedule1 master1   05/08/2008 03:42:26

using below command to print duplicate line with latest time

nawk '!arr[$1]++ || arr[$3]++ || arr[$7]>=1' MediaErr.log

Current Output

84   Server1     Policy1       Schedule1 master1   05/08/2008 02:12:16
84   Server1     Policy1       Schedule1 master1   05/08/2008 03:42:26

but could not get exact output

it should be

84   Server1     Policy1       Schedule1 master1   05/08/2008 02:22:47
84   Server1     Policy1       Schedule1 master1   05/08/2008 03:42:26

:confused: any suggestions

I guess you're looking for the most recent timestamp within an hour for your log file (?).

If sorting is not an issue use:

 
awk '{split($NF,a,":"); b[a[1]]=$0}END{for (i in b) print b}' MediaErr.log

Otherwise sort your file first:

sort -k 7.1,7.2n -k 7.4,7.5n -k 7.7,7.8n  MediaErr.log | awk '{split($NF,a,":"); b[a[1]]=$0}END{for (i in b) print b}'