in reply to Remove duplicate lines in a file
Output:my %seen; my @lines; while (<DATA>) { my @cols = split /\s+/; unless ($seen{$cols[0]}++) { push @lines, $_; } } print @lines; __DATA__ XXXXXS331632 XXXXXS331632 female 40087 a5 XXXXXS331632 XXXXXS331632 female 47735 a5 XXXXXS331681 XXXXXS331681 male 40087 e6 XXXXXS331681 XXXXXS331681 male 47735 e6 XXXXXS331856 XXXXXS331856 male 40177 d1 XXXXXS331856 XXXXXS331856 male 47737 d1
Edit: Misread the question and used the wrong column for the ID.$ ./721691.pl XXXXXS331632 XXXXXS331632 female 40087 a5 XXXXXS331681 XXXXXS331681 male 40087 e6 XXXXXS331856 XXXXXS331856 male 40177 d1
|
|---|