perl -ne 'print if ($seen{$_} .= @ARGV) =~ /^9876543210$/' FILE1 FILE2