I suggest to use sed to collect lines in the hold space to check whether they appeared before:
sed -n 'H;G;/^\(C([^)]*)\).*\1 *\n/d;P'!P' Happends the current line to the hold spaceGappends the hold space with all lines we ever saw to the pattern spaceC([^)]*)is one of thoseC(…)patterns, the^anchors it to the beginning of the line and it's surrounded by\(…\), so it can be backreferenced as\1later. We need\1 *\nas pattern, with the nexlinenewline (after possible whitespaces) to avoid matching the freshly appended line at the end. So the whole pattern/^\(C([^)]*)\).*\1 *\n/matches a line with a duplicateC(…), so weonly if thisd!elete that one doesn't match,- otherwise we
Print everything before the first newline (= without the appended hold space), while default output is suppressed by the-noption
Note that depending on you sed version and file size, this may fail because over the time, all lines will be in memory.