--- David Blevins <[EMAIL PROTECTED]> wrote:
> Truly astounding.
lol
> From: Paul [mailto:[EMAIL PROTECTED]]
> > --- David Blevins <[EMAIL PROTECTED]> wrote:
> > > > perl -nle 'print if !$seen{$_}++'
> > >
> > > $seen{$_}
> > >
> > > Tries to lookup the line in the hash of lines we've alr
Truly astounding.
From: Paul [mailto:[EMAIL PROTECTED]]
>
> --- David Blevins <[EMAIL PROTECTED]> wrote:
> > > perl -nle 'print if !$seen{$_}++'
> >
> > $seen{$_}
> >
> > Tries to lookup the line in the hash of lines we've already seen.
> >
> > $seen{$_}++
> >
> > This is a complete guess, I c
--- David Blevins <[EMAIL PROTECTED]> wrote:
> > perl -nle 'print if !$seen{$_}++'
>
> The dash n (-n) puts the command 'print if !$seen{$_}++' in a while
> (<>) { ... } loop. So we get:
>
> while (<>) {
> print if !$seen{$_}++
> }
>
> $seen{$_}
>
> Tries to lookup the line in the hash
Yikes! This is what I was talking about. Amazing.
Let me take a crack at the first one -- should be entertaining for everyone
;)
From: Jeff 'japhy/Marillion' Pinyan
>
> Here's a one-liner:
>
> perl -nle 'print if !$seen{$_}++'
The dash n (-n) puts the command 'print if !$seen{$_}++' in a wh
On Jul 30, Paul said:
>> while (){
>>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 g
--- Carl Rogers <[EMAIL PROTECTED]> wrote:
> One word of caution it looks to me like this will catch
> duplicates lines, just as long as the duplicate lines follow each
> other. . . .
I posted a one-liner that does the same as the code below. =o)
>
> while (){
>if (not $seen{$_}) {
>
One word of caution it looks to me like this will catch duplicates
lines, just as long as the duplicate lines follow each other. You may want
to do some kind of a sort process prior to running this line of code.
Only reason I bring this up... I've been bitten by this same problem in the
pas
--- David Blevins <[EMAIL PROTECTED]> wrote:
> Here is a one-liner I just wrote to delete duplicate lines in a file.
>
> perl -ni.bak -e 'unless ($last eq $_){print $_};$last=$_;' theFile
That requires that it be sorted, doesn't it?
> Going with the TMTOWTDI credo, I was just curious if anyone