in reply to Re: Removing repeated lines from file
in thread Removing repeated lines from file

This is the only solution, as far, that solves the general problem of repeating lines not only consecutive repeating lines ++. Just fix the name of the hash, now you use two: %read_lines and %read for what should be one I think.

A compression (broquaint based):

perl -ni -e 'print if $seen{$_}; $seen{$_} = 1' your_file

Replies are listed 'Best First'.
Re: Re: Re: Removing repeated lines from file
by jmcnamara (Monsignor) on Jun 24, 2003 at 12:25 UTC

    Here is another variation:
    perl -i.bak -ne 'print unless $h{$_}++' file

    However, since these solutions store unique lines in memory they are potentially slow for very large files.

    --
    John.

Re: Re: Re: Removing repeated lines from file
by ant9000 (Monk) on Jun 24, 2003 at 13:06 UTC
    Ooops... I should never write untested code ;-)