Uma solução Perl:
$ perl -lne '$k{"$_:"}++ for split(/\b/); push @l,$_; }{
map{s/\S+:/$k{$&}<2 ? " " x length($&) : $&/e; print}@l;' file
0f a2 cpuid
a9 01 00 00 00 test eax,0x1
74 01 je a <myFunc+0xa>
c3 ret
a: 0f 0b ud2a
Isso é equivalente a:
#!/usr/bin/perl
use strict;
my %wordsHash;
my @lines;
## Read the input file line by line, saving each
## line as $_. This is what 'perl -n' means.
while (<>) {
## Remove trailing newlines. This is done
## by -l in the one liner.
chomp;
## Split the current line on word boundaries
my @wordsArray=split(/\b/);
## Save each word + ":" as a key in the hash %wordsHash,
## incrementing the value by one each time the word
## is seen.
foreach my $word (@wordsArray) {
$wordsHash{"$word:"}++;
}
## Add the line to the array @lines
push @lines, $_;
}
## After the file has been read. ('}{' in the one-liner)
## Iterate over each line in @lines ( map{}@l in the one-liner)
foreach my $line (@lines) {
## Grab the first set of non-whitespace
## characters until the 1st ':'
$line=~/\S+:/;
## $& is whatever was matched
my $match=$&;
## If the match was seen only once
## as a word (all will be seen at least once)
if ($wordsHash{$match}<2) {
## The replacement is as many spaces
## as $match has characters.
my $rep = " " x length($match);
## Replace it in the line
$line=~s/$match/$rep/;
}
## Print the line
print "$line\n";;
}