busybox sort wrong with -t/-k
Christian Neukirchen
chneukirchen at gmail.com
Thu Sep 17 19:04:43 UTC 2015
Hi,
I noticed the following difference in output:
GNU sort 8.24 and FreeBSD 10.2 sort:
% printf '%s\n' a/a:a a:b | sort -t: -k1
a/a:a
a:b
% printf '%s\n' a/a:a a:b | sort -t: -k1,1
a:b
a/a:a
BusyBox v1.23.2 (2015-08-12 12:31:27 UTC) multi-call binary.
Linux juno 4.1.7_1 #1 SMP PREEMPT Mon Sep 14 04:46:51 UTC 2015 x86_64 GNU/Linux
% printf '%s\n' a/a:a a:b | busybox sort -t: -k1
a/a:a
a:b
% printf '%s\n' a/a:a a:b | busybox sort -t: -k1,1
a/a:a
a:b
-k1 means the rest of the line after field 1 is included, sorting
a/a:a before a:b since '/' comes before ':'.
-k1,1 means that only the first field should be regarded as key, thus
a comes before a/a.
Thanks,
--
Christian Neukirchen <chneukirchen at gmail.com> http://chneukirchen.org
More information about the busybox
mailing list