improve regexp to avoid bogus fails on HPUX

While there, deal with three duplicates: nuke one with identical content, and rename the two others.