Unix下划线字符排序处理 [英] Unix sort treatment of underscore character

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

问题描述

我有两台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

这不会仅更改当前执行sort命令的环境. 您应该对此具有相同的行为.

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屋!

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