SO I have a file - lets call it coocoo
GRNB is missing a regsho on capser0001
SAN-F is missing a regsho on capser0001
PSA-V is missing a regsho on capser0001
BK-C is missing a regsho on capser0001
GRNB is missing a regsho on capser0040
SAN-F is missing a regsho on capser0040
PSA-V is missing a regsho on capser0040
BK-C is missing a regsho on capser0040
All i want is the first column (but don't want to use awk)
so i make a script in perl
Code:
#!/usr/bin/perl
my $column;
my $first_column
open REGSHO, "/tmp/coocoo" or die $!;
while (<REGSHO>) {
chomp $_ ;
my @column = split /\s/, $_;
push @first_column , $column[0];
}
foreach my $elem (@first_column ) {
print "$elem\n"
}
which gives me this
Code:
GRNB
SAN-F
PSA-V
BK-C
GRNB
SAN-F
PSA-V
BK-C
YAY!!!!!!!!!!!!
However I want to keep this unique - so i put i a hash to get rid of the dupes.
Code:
#!/usr/bin/perl
my %seen;
my $column;
my $first_column
open REGSHO, "/tmp/coocoo" or die $!;
while (<REGSHO>) {
chomp $_ ;
my @column = split /\s/, $_;
push @first_column , $column[0];
}
foreach my $elem (@first_column ) {
next if $seen{ $elem }++;
push @first, $elem;
}
foreach my $first (@first) {
print $first;
print "\n" ;
}
which gives me this --- BOOOOOO!!!!
Code:
GRNB
SAN-F
PSA-V
BK-C
GRNB
how do i get rid of the first duplicate GRNB ?
this is so, so easy in bash.