让linux Sort 按照 ASCII 顺序排序

来源:互联网 发布:风力预报软件 编辑:程序博客网 时间:2024/05/24 03:34

1. cat test.txt

c
b
x
d
A
E
f
a
S
u
t
T
S
s

2. sort test.txt

a
A
b
c
d
E
f
s
S
S
t
T
u
x

3. export LC_ALL=C

4. sort test.txt

A
E
S
S
T
a
b
c
d
f
s
t
u
x

Linux下的sort函数是通过locale来判断的,可以将LC_ALL设置为C,从而使得排序按照ASCII,这个问题没想到困扰了我很久。。



0 0
原创粉丝点击