On Jul 30, Paul said:
>> while (<INPUTFILE>){
>> if (not $seen{$_}) {
>> $seen{$_} = 1;
>> print OUTFILE;
>> }
>> else {
>> }
>> }
Here's a one-liner:
perl -nle 'print if !$seen{$_}++'
and here's another:
perl -pe '$_ x= !$seen{$_}++' (attributed to some of Larry's genius)
and another, for use in a program
$seen{$_} ||= print OUT while <IN>;
Have fun. :)
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Re: Deleting Duplicate Lines one-liner
Jeff 'japhy/Marillion' Pinyan Mon, 30 Jul 2001 10:52:57 -0700
- Deleting Duplicate Lines one-liner David Blevins
- is there a module ala getopt::long that... Matt Lyon
- Re: is there a module ala getopt::l... Paul Johnson
- Re: Deleting Duplicate Lines one-liner Paul
- Re: Deleting Duplicate Lines one-liner Carl Rogers
- Re: Deleting Duplicate Lines one-li... Paul
- Re:[OT?]Deleting Duplicate Line... Jeff 'japhy/Marillion' Pinyan
- Re:[OT?]Deleting Duplicate ... Paul
- Re:[OT?]Deleting Dupli... Jeff 'japhy/Marillion' Pinyan
- Re:[OT]Deleting Du... Paul
- Re:[OT?]Deleting D... Peter Scott
- Re:[OT?]Deleti... Peter Scott
- RE: Deleting Duplicate Line... David Blevins
- RE: Deleting Duplicate... Paul
- RE: Deleting Dupli... David Blevins
- RE: Deleting D... Paul
