Categories
Linux Mastering Development

Uniq based on last field, keeping last line, and append number of duplicates

I need some help to implement awk command in a bash script for implementing below logic. Tried sort/uniq combination, but no luck. I have a long list with time stamp and some number in front of it like below. [2020-09-15 09:03:21.835335] 1021 [2020-09-15 09:03:21.935335] 1021 [2020-09-15 09:03:22.835335] 1022 [2020-09-15 09:03:25.835335] 1022 [2020-09-15 09:04:21.835335] 1023 [2020-09-15 […]