Different versions of UNIX sort handle case differently

瘦欲@ 提交于 2020-01-15 07:35:55

问题


I am using sort both on Mac OS X and Ubuntu Linux, and I am observing a different handling of uppercase/lowercase comparisons.

On Mac OS X, sort (GNU coreutils) 5.93 gives the behavior I expect:

$ sort <<EOF
> Aa
> aa
> Ab
> ab
> EOF
Aa
Ab
aa
ab

On Ubuntu, sort (GNU coreutils) 8.5 seems to ignore case:

$ sort <<EOF
> Aa
> aa
> Ab
> ab
> EOF
aa
Aa
ab
Ab

Is there a way to disable this behavior? I need case-sensitive sort. I tried to change the LOCALE to C and nothing changed.

Alternatively, is there any other simple utility that sorts large files treating each line just as a byte string?


回答1:


try using POSIX: 'export LANG=POSIX'



来源:https://stackoverflow.com/questions/7090390/different-versions-of-unix-sort-handle-case-differently

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!