Re: uniq without sort <-------------- GURU NEEDED
am 25.01.2008 07:05:09 von Ed MortonOn 1/24/2008 8:45 PM, gnuist006@gmail.com wrote:
> This is a tough problem, and needs a guru.
>
> I know it is very easy to find uniq or non-uniq lines if you scramble
> all of them and sort them. Its trivially
>
> echo -e "a\nc\nd\nb\nc\nd" | sort | uniq
Actually, you'd just use "sort -u" for that rather than "sort
| uniq".
> $ echo -e "a\nc\nd\nb\nc\nd"
> a
> c
> d
> b
> c
> d
>
> $ echo -e "a\nc\nd\nb\nc\nd"|sort|uniq
> a
> b
> c
> d
>
>
> So it is TRIVIAL with sort.
>
> I want uniq without sorting the initial order.
>
$ echo -e "a\nc\nd\nb\nc\nd" | awk '!a[$0]++'
a
c
d
b
Regards,
Ed.