Unix下划线字符的排序处理 [英] Unix sort treatment of underscore character
问题描述
我有两台 linux 机器,在这台机器上 unix 排序似乎表现不同.我相信我已将其范围缩小到处理下划线字符.
I have two linux machines, on which unix sort seems to behave differently. I believe I've narrowed it down to the treatment of the underscore character.
如果我运行 sort tmp
,其中 tmp 包含以下两行:
If I run sort tmp
, where tmp contains the following two lines:
aa_d_hh
aa_dh_ey
一台机器输出
aa_d_hh
aa_dh_ey
(即_"在h"之前)而其他输出
(i.e. '_' precedes 'h') while the other outputs
aa_dh_ey
aa_d_hh
(即h"在_"之前).我需要这些机器一起运行(因为我稍后使用 sort -m 来合并非常大的文件).
(i.e. 'h' precedes '_'). I need these machines to behave together (as I use sort -m later, to merge very large files).
有什么方法可以强制排序以一种或另一种方式运行?
Is there any way I can force sort to behave in one way or the other?
谢谢.
推荐答案
您可以将 LC_COLLATE
设置为仅针对您的命令的传统排序顺序:
You can set LC_COLLATE
to traditional sort order just for your command:
env LC_COLLATE=C sort tmp
这不会改变当前环境,只是改变排序命令执行的环境.您应该对此有相同的行为.
This won't change the current environment just the one in which the sort command executes. You should have the same behaviour with this.
这篇关于Unix下划线字符的排序处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!