Code:
#!/usr/bin/perl -w
while (<STDIN>)
{
push (@lines, $_);
}
print "-\n";
foreach my $i (@lines)
{
if (scalar (grep { /$i/ } @lines) == 1)
{
print $i;
}
}
Usage:
Code:
Tsunami repeated_lines # perl repeat.pl
pqr
def
abc
lmn
pqr
abc
mkh
hgf
-
def
lmn
mkh
hgf
Tsunami repeated_lines #
To stop input, just hit Ctrl-D and the script will give you all the non-repeated strings in the input order.
You can also do something like:
Code:
Tsunami repeated_lines # cat lines |perl repeat.pl
-
def
lmn
mkh
hgf
Tsunami repeated_lines # cat lines
pqr
def
abc
lmn
pqr
abc
mkh
hgf
Tsunami repeated_lines #
|