【发布时间】:2013-11-07 09:47:13
【问题描述】:
我必须处理sort 似乎无法处理的文件。
这些文件是 apprx。每个 3 GB。
输入如下:
last-j nmod+j+n year-n 9492
last-j nmod+j+n night-n 8075
first-j nmod+j+n-the time-n 7749
same-j nmod+j+n-the time-n 7530
other-j nmod+j+n-the hand-n 5319
ast-j nmod+j+n year-n 1000
last-j nmod+j+n night-n 5000
first-j nmod+j+n-the time-n 1000
same-j nmod+j+n-the time-n 3000
other-j nmod+j+n-the hand-n 200
我需要将相应重复的数量相加。
所以想要的输出如下:
last-j nmod+j+n year-n 10492
last-j nmod+j+n night-n 13075
first-j nmod+j+n-the time-n 8749
same-j nmod+j+n-the time-n 10530
other-j nmod+j+n-the hand-n 5519
我一直在尝试这个排序命令,应该可以解决问题
sort input | uniq -c | awk '{print $2 "\t" $3 "\t" $1*$4}'
它的内存不足。关于可能更优化以处理更大数据文件的任何建议?谢谢
【问题讨论】:
-
如何定义重复项?相同的三列?添加预期输出,使其更清晰。
-
查看更新的问题 -- 我包含了想要的结果。
-
目前还不清楚你想要什么。为什么输出包含两行
other-j nmod+j+n-the hand-n? -
对不起!更新了所需的结果 - 它们现在是准确的,我在编写时出错了。它只是将 Cols 1-3 中的重复项相加并添加频率。在 Col4