perl -ne 'print if ++$seen{$_} == 2' fileA fileB