sort -m locale? - Suse

This is a discussion on sort -m locale? - Suse ; I'm having a terrible time trying to figure out what is going on with sort on my machine. I'm trying to get sort by month working. After much playing around I found an article by Jerry Peek talking about using ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: sort -m locale?

  1. sort -m locale?

    I'm having a terrible time trying to figure out what is going on with
    sort on my machine. I'm trying to get sort by month working. After much
    playing around I found an article by Jerry Peek talking about using
    sort. Trying the examples in the article I get something like this.

    $cat stan
    Jun 3 2005 Rehired
    Jun 13 2005 Fired
    Mar 15 2005 Fired
    Mar 16 2003 Hired
    Mar 6 2004 Promoted

    $sort -k 3,3 stan
    Mar 16 2003 Hired
    Mar 6 2004 Promoted
    Jun 13 2005 Fired
    Jun 3 2005 Rehired
    Mar 15 2005 Fired

    so far so good, now for months

    $sort -k 3,3 -k 1,1M stan
    Mar 16 2003 Hired
    Mar 6 2004 Promoted
    Jun 13 2005 Fired
    Jun 3 2005 Rehired
    Mar 15 2005 Fired

    so the month is not working. I have tried with only months in a single
    column and get the same results. I'm fairly sure the problem lies with
    locales. On this particular machine I'm running Suse 10.0 which has

    sort (GNU coreutils) 5.3.0

    and my locale stuff is set like this:

    $locale
    LANG=en_US.UTF-8
    LC_CTYPE="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_PAPER="en_US.UTF-8"
    LC_NAME="en_US.UTF-8"
    LC_ADDRESS="en_US.UTF-8"
    LC_TELEPHONE="en_US.UTF-8"
    LC_MEASUREMENT="en_US.UTF-8"
    LC_IDENTIFICATION="en_US.UTF-8"
    LC_ALL=

    I've tried several other incantations like C, POSIX, en_US, and I think
    I tried HELP but nothing seems to make any difference.

    I'm aware there are many workarounds for this problem and I'm not really
    looking for a workaround; I'd like to find out why sort won't work.

    I'm not sure about date, but from the man page it appears that date uses
    the locale also and date +%b prints Mar so it appears like the locale is
    set to a sensible and compatible setting.

    Any ideas?

    I also posted this message earlier to comp.unix.shell and so far no joy
    so I thought I'd try here in Suseland.

  2. Re: sort -m locale?

    stan wrote:
    > I'm having a terrible time trying to figure out what is going on with
    > sort on my machine. I'm trying to get sort by month working. After much
    > playing around I found an article by Jerry Peek talking about using
    > sort. Trying the examples in the article I get something like this.


    I tend to not like following up my own post, but I want to get this on
    the record just i case someone else runs into this issue.

    I thnk it's too late for bug reports regarding suse 10.0, so I'll just
    post the issue here. The sort from the coreutils 5.3.0 has a bug
    introduced when they updated to coreutils 5.3.0-20 as an online update.

    The issue is that sort by months (sort with the -M flag) doesn't work.
    The month value read from the input is converted to upper case properly
    as it should be. The month value read from the system using the locale
    is in upeer and lower case. So sort compares JAN == Jan and the
    comparison gives bogus results. The code to fix this is trivial, but I
    don't why anyone would care as everyone has pretty much moved on to newer
    supported versions; as I'm also doing but at a snails pace.


+ Reply to Thread