Subject: Re: sort -urn losing data
To: <>
From: Ignatios Souvatzis <is@netbsd.org>
List: tech-userlevel
Date: 01/20/2006 11:20:32
On Thu, Jan 19, 2006 at 03:04:56PM -0800, Jeremy C. Reed wrote:
> "sort -urn" loses data versus "sort -rn | sort -u".
> 
> I don't know if this is a misunderstanding or misuse of options
> or if this is a bug.
> 
> Using this data:
>    1 callrpc
>    1 tzset
>    1 callrpc
> sort -rnu will return:
>    1 callrpc
> 
> And using this data:
>    1 tzset
>    1 callrpc
>    1 callrpc
> sort -rnu will return:
>    1 tzset
> 
> Both examples above (I believe) have wrong output.
> 
> After several other tests, it appears that the -n in addition to -u makes 
> it lose data.
> 
> Or is this correct behaviour?

sort -n interprets the whole sort field as a number, then does your -u 
on the sort field used, with the method used, so yes, this is expected.
At least by me.

You want, afaict,

sort -rn +1 -2 | sort -u +2 -3, right?

	-is