bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sort and multiple -k options


From: Mike Frysinger
Subject: sort and multiple -k options
Date: Sun, 28 Jun 2009 01:42:05 -0400
User-agent: KMail/1.11.3 (Linux/2.6.29.4; KDE/4.2.3; x86_64; ; )

i cant figure out if i'm doing something stupid here or sort is doing 
something wrong ...

consider this (reduced) input:
/path/._cfg0000_asciidoc.conf%/path/%._cfg0000_%asciidoc.conf
/path/._cfg0000_docbook.conf%/path/%._cfg0000_%docbook.conf
/path/._cfg0001_asciidoc.conf%/path/%._cfg0001_%asciidoc.conf

i want to have the files sorted by (1) path then (2) file name then (3) cfg 
order.  so i use this:
sort -t% -k2 -k4 -k3

but i keep getting the same output as my input:
$ cat f | sort -t% -k2 -k4 -k3
/path/._cfg0000_asciidoc.conf%/path/%._cfg0000_%asciidoc.conf
/path/._cfg0000_docbook.conf%/path/%._cfg0000_%docbook.conf
/path/._cfg0001_asciidoc.conf%/path/%._cfg0001_%asciidoc.conf

even if i try just (1) and (2), it still doesnt sort:
$ cat f | sort -t% -k2 -k4
/path/._cfg0000_asciidoc.conf%/path/%._cfg0000_%asciidoc.conf
/path/._cfg0000_docbook.conf%/path/%._cfg0000_%docbook.conf
/path/._cfg0001_asciidoc.conf%/path/%._cfg0001_%asciidoc.conf

if however i cut out field 3, then it seems to sort properly:
$ cat f | cut -d% -f1,2,4 | sort -t% -k2 -k3
/path/._cfg0000_asciidoc.conf%/path/%asciidoc.conf
/path/._cfg0001_asciidoc.conf%/path/%asciidoc.conf
/path/._cfg0000_docbook.conf%/path/%docbook.conf

using coreutils 7.4 here, and locale doesnt seem to matter (forcing to C gets 
same result).  there are no custom patches to the source in Gentoo.
-mike





reply via email to

[Prev in Thread] Current Thread [Next in Thread]