GNU bug report logs - #11900
Sort by month fails if not in first field or first position

Previous Next

Package: coreutils;

Reported by: jim <at> smartots.com

Date: Tue, 10 Jul 2012 16:07:02 UTC

Severity: normal

Tags: notabug

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #10 received at control <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: jim <at> smartots.com
Cc: 11900 <at> debbugs.gnu.org
Subject: Re: bug#11900: Sort by month fails if not in first field or first
	position
Date: Tue, 10 Jul 2012 18:11:16 +0100
tag 11900 + notabug
close 11900
stop

On 07/10/2012 08:42 AM, jim <at> smartots.com 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.




This bug report was last modified 12 years and 318 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.