Re: uniq without sort <-------------- GURU NEEDED
gnuist006 [at] gmail.com wrote:
<snip>
> 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
On Fri, 25 Jan 2008 06:14:03 -0800, William Ahern wrote:
> gnuist006 [at] gmail.com wrote:
> <snip>
>> 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