通过UNIX中的单个列合并两个文件 [英] Merging two files by a single column in unix
本文介绍了通过UNIX中的单个列合并两个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在UNIX中按一列合并两个文件.
I would like to merge two files by one column in unix.
我有file_a:
subjectid name age
12 Jane 16
24 Kristen 90
15 Clarke 78
23 Joann 31
我还有另一个file_b:
I have another file_b:
subjectid prob_disease
12 0.009
24 0.738
15 0.392
23 1.2E-5
我想在命令行中合并这些文件.我想按主题合并文件a和b.由于每个文件的长度约为200万行,因此我在R中进行了尝试,但由于数据量而冻结,有人可以帮助我在Linux中进行此操作吗? 所需的输出:
I would like to merge these files in the command line. I'd like to merge files a and b by subjectid. Since each file is about 2 million lines long, I tried in R but it froze due to the amount of data, could someone please help me do this in linux? Desired output:
subjectid prob_disease name age
12 0.009 Jane 16
24 0.738 Kristen 90
15 0.392 Clarke 78
23 1.2E-5 Joanna 31
请帮忙,谢谢!
推荐答案
签出 join(1)
.就您而言,您甚至不需要任何标志:
Check out join(1)
. In your case, you don't even need any flags:
$ join file_b file_a
subjectid prob_disease name age
12 0.009 Jane 16
24 0.738 Kristen 90
15 0.392 Clarke 78
23 1.2E-5 Joann 31
这篇关于通过UNIX中的单个列合并两个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文