Subject: sort -urn losing data
To: None <tech-userlevel@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-userlevel
Date: 01/19/2006 15:04:56
"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?

My workaround for now is to pipe the sort -u output into another sort -rn.

I noticed this when I merged a few files and I lost numerous entries.

 Jeremy C. Reed

 	  	 	 BSD News, BSD tutorials, BSD links
	  	 	 http://www.bsdnewsletter.com/