I have a file A of lines of equal length n. I have a program that for each line in A can output a line of length n which its key. The program can either write the sequence of keys for the lines in A into a file B or write them to stdout for each line of A.
I need to obtain all lines of A so that the respective keys do not get repeated.. What would be the most efficient way to accomplish this? I see that there is a -k option in sort but it doesn't quite seem to do what I want.
Edit. To clarify on the comment.
Suppose that A contains the lines
foo
bar
baz
and that the second program computing the keys for these lines outputs
xxx
yyy
xxx
where the first line is the otput for foo, the second for bar and third for baz.
Then one of the correct outputs would be
foo
bar
foo
shouldn't be in the output as it doesn't have an unique key... or you should change your question.