Re: uniq without sort <-------------- GURU NEEDED

Re: uniq without sort <-------------- GURU NEEDED

am 25.01.2008 15:14:03 von William Ahern

gnuist006@gmail.com wrote:

> I want uniq without sorting the initial order.

My AWK is rusty, but this should work:

awk '!seen[$0] { seen[$0] = $0; print $0 }'

Not sure how empty lines would work out.

Re: uniq without sort <-------------- GURU NEEDED

am 25.01.2008 15:24:28 von Stephane CHAZELAS

On Fri, 25 Jan 2008 06:14:03 -0800, William Ahern wrote:
> gnuist006@gmail.com wrote:
>
>> I want uniq without sorting the initial order.
>
> My AWK is rusty, but this should work:
>
> awk '!seen[$0] { seen[$0] = $0; print $0 }'
>
> Not sure how empty lines would work out.

Empty lines or lines containing "0" or "00"... would be printed
every time.

awk '!($0 in seen) {seen[$0] = ""; print}'

Ed also gave a condensed version.

--
Stephane