problem wth sort utility?

Cameron Simpson cs at zip.com.au
Fri Jul 1 09:16:29 UTC 2011


On 01Jul2011 17:00, Michael D. Setzer II <mikes at kuentos.guam.net> wrote:
| I'm getting results that I don't expect and different from busybox 
| sort?
[...]
| [sda3            ] [ext3       ] [<unknown>        ] [   434.38 GB] [  8] [  3] 
| [sda             ] [Hitachi HDP72505               ] [   465.76 GB] [  8] [  
| 
| Which is not what I expect with sda coming at the end instead of 
| before sda1, and there are just spaces between all the charcters, 
| no special codes.
| 
| Using busybox sort results in this. [...]
| [sda             ] [Hitachi HDP72505               ] [   465.76 GB] [  8] [  
| [sda1            ] [ext3       ] [<unknown>        ] [   200.00 MB] [  8] [  
[...]
| Which is what I expect?
| If I create a file with just the disk and partition info, both sorts give 
| me the correct sorts. Even if I put spaces afterwards it sorts fine, 
| but if I put non-blanks it puts the sda at the end?

1: Please show us your command line.
   I'm imagining something like:
     sort < filename

2: What tool are you using to create the file?
   It is possible you are using something other than a space or TAB in
   the Fedora file. There are Unicode codepoints for spaces in addition
   to the usual two (space:32, tab:9).

Both space and tab sort lexically before digits (which start at 48 for
"0"). If you're using another whitespace codepoint by accident then it
will probably come above the digits and thus change the sort result.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

I must not fear.  Fear is the mind-killer.  Fear is the little death that
brings total obliteration.  I will face my fear.  I will permit it to pass
over me and through me.  And when it has gone past I will turn the inner eye
to see its path.  Where the fear has gone there will be nothing.  Only I will
remain.
        - Frank Herbert _Dune_


More information about the users mailing list