quote:
I wouldn't have considered this a bug since it is exactly how the sort in OpenBSD works.
We have different ideas about what a bug is, then. Yours appears to be disagreement with an existing popular implementation (OpenBSD). Mine is disagreement with the specified behavior (the man page), enhanced by the fact that it's an inconsistent disagreement (140, 149, 141 vs. 49, 41, 40). Besides, I've been using UNIX sort for almost 30 years, so I know a bug when I see it :-)
quote:
The -nrk2 switch does what you want.
As Rodney noted, it doesn't do what I want in all cases. For example, in
echo '20\n140 11\n149\n140 2\n140 33' | sort -k1nr,1 -k2,2 (note that the secondary key should not be sorted numerically), the documented behavior (which Solaris sort and GNU sort 6.1 exhibit) yields
149
140 11
140 2
140 33
20 I see no way to use the workaround of using an option instead of a modifier letter. For example, this attempt
echo '20\n140 11\n149\n140 2\n140 33' | sort -nrk1,1 -k2,2 produces
149
140 33
140 11
140 2
20 which is not what I want. There is no "nonnumeric" or "nonreverse" option to try.
|