Here's a simple way:
tac FILE | uniq -w 6 | tac
We:
- Reverse-print the file using
tac
(necessary foruniq
to work right here). - Weed out duplicate lines basing uniqueness on only the first 6 characters (thereby ignoring the incrementing number in parantheses). Only the first line of a set of duplicate lines is kept, which is why we have used
tac
. - Then reverse-print the file again so it's in the order you want.