问题
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