我有一个文件,每个文件都有两个字符:
$ cat roman
Ⅱ
Ⅲ
当我用sort -u
对此文件进行排序时,只显示一行:
$ sort -u roman
Ⅱ
Ⅱ
是代码点U + 2161,Ⅲ
是代码点U + 2162。为什么只显示一行?
修改
$ xxd -g 1 roman
0000000: e2 85 a1 0a e2 85 a2 0a ........
$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=
我的sort
属于GNU coreutils。
$ sort --version
sort (GNU coreutils) 8.15
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and Paul Eggert.
答案 0 :(得分:1)
尝试设置LC_COLLATE=C
;那解决了吗?这对我有用:
$ export LANG=en_US.UTF-8
$ export LANGUAGE=en_US:en
$ export LC_CTYPE="en_US.UTF-8"
$ export LC_NUMERIC=en_US.UTF-8
$ export LC_TIME=en_US.UTF-8
$ export LC_COLLATE="en_US.UTF-8"
$ export LC_MONETARY=en_US.UTF-8
$ export LC_MESSAGES="en_US.UTF-8"
$ export LC_PAPER=en_US.UTF-8
$ export LC_NAME=en_US.UTF-8
$ export LC_ADDRESS=en_US.UTF-8
$ export LC_TELEPHONE=en_US.UTF-8
$ export LC_MEASUREMENT=en_US.UTF-8
$ export LC_IDENTIFICATION=en_US.UTF-8
$ export LC_ALL=
$ sort -u foo.txt |wc -l # <-- with your env variables
1
$ export LC_COLLATE=C
$ sort -u foo.txt |wc -l # <-- with LC_COLLATE changed to C
2
查看我的/ usr / share / i18n / locales / en_US副本,我看到了:
LC_COLLATE
% Copy the template from ISO/IEC 14651
copy "iso14651_t1"
END LC_COLLATE
这可能是来自哪里。不知道为什么它会告诉这些人整理在一起。