Re: deleting duplicate lines and ignoring whitespace

From: rakesh sharma (sharma__r_at_hotmail.com)
Date: 05/19/04


Date: 18 May 2004 23:04:51 -0700

heller4@llnl.gov (Sam Heller) wrote in message news:

>
> I am familiar with the uniq program, but am trying to find a way to
> delete lines while ignoring embedded and external whitespaces.
> For example I would like the following:
>
> 123 4 567 8910
> 1 234567 8 910
> 1345
>
>
> to become
>
> 123 4 567 8910
> 1345
>
>
> It doesn't matter which of the duplicate lines is kept. The problem
> is that if someone put an extra space between columns or endedded with
> an extra space then the lines will be considered different, even
> though they contain the same data.
>

    sed -e '$q;N;h;/^\(.*\)\n\1$/{g;D;};g;P;D' yourfile



Relevant Pages

  • Re: deleting duplicate lines and ignoring whitespace
    ... Sam Heller wrote: ... >I am familiar with the uniq program, but am trying to find a way to ... >It doesn't matter which of the duplicate lines is kept. ... >an extra space then the lines will be considered different, ...
    (comp.unix.questions)
  • Re: deleting duplicate lines and ignoring whitespace
    ... Sam Heller wrote: ... > delete lines while ignoring embedded and external whitespaces. ... First remove the unwanted text then sort. ... > an extra space then the lines will be considered different, ...
    (comp.unix.questions)
  • deleting duplicate lines and ignoring whitespace
    ... I am familiar with the uniq program, but am trying to find a way to ... delete lines while ignoring embedded and external whitespaces. ... an extra space then the lines will be considered different, ... Sam ...
    (comp.unix.questions)