perl -lne 'exists $h{$_} ? print "$_ in $h{$_} and $ARGV" : ($h{$_} = $ARGV)' file1 file2 #### perl -F: -lane 'exists $h{$F[2]} ? print "$F[2] in $h{$F[2]} and $ARGV" : ($h{$F[2]} = $ARGV)' passwd1 passwd2