I ran into basically the same confusion as Eugen while trying to figure 
out some bugs in busybox sort and comparing the output to GNU sort.

I found the following page which gives valuable pointers to why the syntax
"-k2,3n", or even worse "-k2nr,3n", are not supported:
http://www.gnu.org/software/coreutils/manual/html_node/coreutils_28.html

This has:
`-t separator' 
[...] But note that sort fields that extend to the end of the line, as `-k 
2', or sort fields consisting of a range, as `-k 2,3', retain the field 
separators present between the endpoints of the range.

and:
Note that if you had written `-k 2' instead of `-k 2,2' sort would have 
used all characters beginning in the second field and extending to the 
end of the line as the primary numeric key. For the large majority of 
applications, treating keys spanning more than one field as numeric will 
not do what you expect. 
Also note that the `n' modifier was applied to the field-end specifier for 
the first key. It would have been equivalent to specify `-k 2n,2' or `-k 
2n,2n'. All modifiers except `b' apply to the associated field, 
regardless of whether the modifier character is attached to the 
field-start and/or the field-end part of the key specifier.

Maybe these very valuable pointers could be added in the manpage.


Hmm. I now see that this information is available in the *info* page for 
sort. Unfortunately, 'info sort' (as suggested in the manpage) does not 
give the info page, but rather the plain manpage.
Only the non-intuitive 'info coreutils' followed by browsing to the sort 
command finds it.

Cheers,
FJP

Attachment: pgpx41y4x0OYt.pgp
Description: PGP signature

Reply via email to