sort

Help
2010-02-04
2012-07-26
  • graham lawrence

    graham lawrence - 2010-02-04

    Is it possible to do an ascii sort on a windows machine?

    I've tried all the usual suspects, LC, LANG etc, both unset and set to various
    values recommended in the archive, but all I ever get is case-insensitive
    sort.

    xp pro + sp3

    Thank you for your help

     
  • Jay Satiro

    Jay Satiro - 2010-02-04

    Check GetGnuWin32:

    https://sourceforge.net/projects/getgnuwin32/files/

    If you look in the bin dir you'll see sort-7.6.exe that I compiled from
    coreutils 7.6. You don't need to run download.bat or install.bat.

    It's a test build that I put out a while ago. Try that and tell me if it
    works. LC_ALL is respected in that build.

    run sort-7.6 --help for more

     
  • graham lawrence

    graham lawrence - 2010-02-07

    Thank you for the help, but I appear to be doing something wrong. I can't find
    any bin folder at https://sourceforge.net/projects/getgnuwin32/files

    All I found in the folder getgnuwin32 was a folder 0.6.30 and a folder Old
    Versions and neither contained any bin folder.

     
  • Jay Satiro

    Jay Satiro - 2010-02-07

    Download GetGnuWin32-0.6.3.exe, run the exe to unzip. In its bin subdirectory
    will be sort-7.6

     
  • graham lawrence

    graham lawrence - 2010-02-07

    Thank you very much. That did the job.

     
  • Joel Korhonen

    Joel Korhonen - 2012-05-02

    I tried sort-7.6 but I have a problem with the -t option.

    The problem is I need to use < as the field separator since my input is an XML
    file. I could match the beginning tag with a fixed position but the problem
    then is matching the closing tag as the contents if variable length. Matching
    with < doesn't seem to be possible since < is a redirector in DOS. I tested it
    in Win 7's cmd.exe.

    This doesn't work:

    sort -t < -k 3,3 --output=out.xml input.xml

    In Linux it works.

    I read Info for Linux's sort and it says one can represent hex 0 by using -t
    '\0' but that doesn't work either:

    multi-character tab `\'\0\''

    I thought I could use '\60' to match < but actually even Linux sort allows
    only \0...

     
  • Joel Korhonen

    Joel Korhonen - 2012-05-02

    Sorry, a correction, I meant this works in Linux:

    sort -t '<' -k 3,3 --output=out.xml input.xml

    but sort-7.6.exe interprets the < as a redirector:

    The system cannot find the file specified.

     
  • Gerhard Sprenger

    Use

    sort -t "<" -k 3,3 --output=out.xml input.xml

    i.e. enclose the less sign in double quotes.

    but sort-7.6.exe interprets the < as a redirector:

    It's your Windows shell (cmd.exe) which interprets the less sign,

    not sort. Sort never "sees" the less sign unless you protect it

    by double quotes.

     
  • Gerhard Sprenger

    Use

    sort -t "<" -k 3,3 --output=out.xml input.xml

    i.e. enclose the less sign in double quotes.

    but sort-7.6.exe interprets the < as a redirector:

    It's your Windows shell (cmd.exe) which interprets the less sign,

    not sort. Sort never "sees" the less sign unless you protect it

    by double quotes.