$ perl -Mstrict -Mwarnings -E ' open my $inFH, q{<}, \ < ) { my $first = ( split )[ 0 ]; $counts{ $first } ++; push @lines, [ $_, \ $counts{ $first } ]; } print for map { $_->[ 0 ] } grep { ${ $_->[ 1 ] } == 1 } @lines;' hello 1234 5698 7458 good_day 1458 good_morning 4758 $