Unix排序产生错误的输出

时间:2014-04-01 19:37:19

标签: python sorting unix hadoop

我正在尝试通过执行以下操作来测试hadoop流媒体作业的mapper和reducer函数:

    cat data.txt | python mapper.py | sort | python reducer.py

但是映射器的排序输出不正确。

he the  1
i       1
i dog   1
i like  1
i'm     1
i'm rob 1
i'm the 1
i the   1 ### this should be after "i like 1" ###
lazy    1

我让其他人在他们的机器上进行测试,他们使用完全相同的映射器函数和命令行执行获得正确的输出。所以我的Unix排序似乎出了问题。

如果这有帮助:

echo $TERM
> vt100 

任何有关尝试或设置不同的建议都将非常感激。感谢

1 个答案:

答案 0 :(得分:5)

您的回答是here,而且是关于区域设置的。简而言之,你应该使用

cat data.txt | python mapper.py | LC_COLLATE=C sort
相关问题