NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/61048: sort(1) not behaving as expected, requiring two passes
The following reply was made to PR bin/61048; it has been noted by GNATS.
From: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: bin/61048: sort(1) not behaving as expected, requiring two passes
Date: Mon, 23 Nov 2026 06:51:38 -0000 (UTC)
gnats-admin%NetBSD.org@localhost ("greywolf%starwolf.com@localhost via gnats") writes:
>sort -nrt- -k2,3,4
>it seems to sort by field 2, reversed and then by field 3, forward.
The -k option is [-k [kstart[,kend]], so kstart=2 and kend=3, the
trailing ",4" is ignored. The single sort key is therefore the
value spanning fields 2 to 3 including the separator, e.g. "11-1".
The numeric comparison of that field then ignores all the trailing
characters beginning from the separator.
What you probably want is:
sort -nrt- -k2 -k3 -k4
to sort by fields 2, 3 and 4 individually.
Home |
Main Index |
Thread Index |
Old Index