不同版本的UNIX排序方式不同 [英] Different versions of UNIX sort handle case differently

查看:89
本文介绍了不同版本的UNIX排序方式不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac OS X和Ubuntu Linux上都使用sort,并且观察到大写/小写比较的不同处理方式.

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

在Mac OS X上,sort (GNU coreutils) 5.93给出了我期望的行为:

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

在Ubuntu上,sort (GNU coreutils) 8.5似乎忽略了大小写:

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

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

是否有禁用此行为的方法?我需要区分大小写的排序. 我试图将LOCALE更改为C,但没有任何改变.

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?

推荐答案

尝试使用POSIX:'export LANG = POSIX'

try using POSIX: 'export LANG=POSIX'

这篇关于不同版本的UNIX排序方式不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆