heh.. it's quite a golf approach.. but it works.
(haven't tested it on a huge file .. i'm too lazy 4 now)
couldn't this be done better (more efficiently)?
perl -e 'push(@_,$_)while<>;foreach(@_){if(!exists$l{$_}){print;$l{$_} +=0}}' <inputfile

Replies are listed 'Best First'.
RE (tilly) 1: remove duplicate lines from input file
by tilly (Archbishop) on Sep 08, 2000 at 15:12 UTC
    How about:
    perl -ne 'print if 1 == ++$seen{$_}' file
    Incidentally I was involved in an interesting discussion of this topic not long ago. Some interesting material in there, including internal design philosophy differences between Python and Perl, how to handle very large files, and the fact that Java won. :-(
      or: perl -ne '$seen{$_}++ or print' file
        Or even (golf alert): perl -ne '${$_}||=print' file (although it's not strict compliant, and breaks if strings have NULLs in them).

        $_="goto+F.print+chop;\n=yhpaj";F1:eval
        If you follow the thread I linked you would find discussion of essentially that alternative. Using ++$seen{$_} was noticably faster because you avoid unnecessary scalar creation.