Let's say that I have the following text in a file:
foo.bar.baz
bar.baz
123.foo.bar.baz
pqr.abc.def
xyz.abc.def
abc.def.ghi.jkl
def.ghi.jkl
How would I remove duplicates from the file, on the basis of postfixes? The expected output without duplicates would be:
bar.baz
pqr.abc.def
xyz.abc.def
def.ghi.jkl
(Consider foo.bar.baz
and bar.baz
. The latter is a substring postfix so only bar.baz
remains. However, neither of pqr.abc.def
and xyz.abc.def
are not substring postfixes of each other, so both remain.)