Subject: Re: sort -urn losing data
To: None <email@example.com>
From: Jeremy C. Reed <firstname.lastname@example.org>
Date: 01/19/2006 16:03:55
On Thu, 19 Jan 2006, 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.
I was asked to compare this with other systems. I see that both DragonFly
1.5.0-DEVELOPMENT's sort(1) and coreutils 5.2.1 sort have the same
behaviour (of losing lines).
I guess if three different sorts behave the same maybe it is correct.
But the -u switch is defined (from The Open Group manual page) as "Unique:
suppress all but one in each set of lines having equal keys."
But it also says "... when the -u option is specified, lines that
otherwise compare equal shall be ordered as if none of the options -d, -f,
-i, -n, or -k were present ..."
Also I forgot to indicate the sort I am using:
$NetBSD: crt0.c,v 1.13 2003/07/26 19:24:27 salo Exp $
$NetBSD: append.c,v 1.13 2004/02/15 11:52:12 jdolecek Exp $
$NetBSD: fields.c,v 1.18 2004/03/14 21:12:14 heas Exp $
$NetBSD: files.c,v 1.23 2004/02/15 11:52:12 jdolecek Exp $
$NetBSD: fsort.c,v 1.30 2004/02/15 11:54:17 jdolecek Exp $
$NetBSD: init.c,v 1.15 2004/02/18 20:44:36 jdolecek Exp $
$NetBSD: msort.c,v 1.17 2004/02/17 19:09:36 jdolecek Exp $
$NetBSD: sort.c,v 1.40 2004/03/14 21:09:30 heas Exp $
$NetBSD: tmp.c,v 1.11 2003/08/07 11:32:34 jdolecek Exp $
> My workaround for now is to pipe the sort -u output into another sort -rn.
Jeremy C. Reed
technical support & remote administration