[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#11900: Sort by month fails if not in first field or first position
From: |
Pádraig Brady |
Subject: |
bug#11900: Sort by month fails if not in first field or first position |
Date: |
Tue, 10 Jul 2012 18:11:16 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 |
tag 11900 + notabug
close 11900
stop
On 07/10/2012 08:42 AM, address@hidden wrote:
> echo -e "1 qFeb\n1 qJan" | sort -k2.2,2.5M
Yep that's a tricky one, but specified by POSIX.
--debug is very useful here...
$ echo -e "1 qFeb\n1 qJan" | sort --debug -k2.2,2.5M
sort: using ‘en_US.utf8’ sorting rules
sort: leading blanks are significant in key 1; consider also specifying 'b'
1 qFeb
^ no match for key
______
1 qJan
^ no match for key
______
Now you might think you can just specify -b, but...
$ echo -e "1 qFeb\n1 qJan" | sort --debug -b -k2.2,2.5M
sort: using ‘en_US.utf8’ sorting rules
sort: leading blanks are significant in key 1; consider also specifying 'b'
sort: option '-b' is ignored
1 qFeb
^ no match for key
______
1 qJan
^ no match for key
______
So you might then think you could add 'b' to the full key, but...
$ echo -e "1 qFeb\n1 qJan" | sort --debug -b -k2.2,2.5Mb
sort: using ‘en_US.utf8’ sorting rules
sort: leading blanks are significant in key 1; consider also specifying 'b'
1 qFeb
^ no match for key
______
1 qJan
^ no match for key
______
So what you really need to do is:
$ echo -e "1 qFeb\n1 qJan" | sort --debug -k2.2b,2.5Mb
sort: using ‘en_US.utf8’ sorting rules
1 qJan
___
______
1 qFeb
___
______
cheers,
Pádraig.