Merging two files by a single column in unix Merging two files by a single column in unix unix unix

Merging two files by a single column in unix


Check out join(1). In your case, you don't even need any flags:

$ join file_b file_asubjectid prob_disease name age12 0.009 Jane 1624 0.738 Kristen 9015 0.392 Clarke 7823 1.2E-5 Joann 31


You're looking for the join command:

$ cat test.112 Jane 1624 Kristen 9015 Clarke 7823 Joann 31 $ cat test.212 0.00924 0.73815 0.39223 1.2E-5 $ join -j1 -o 2.1,2.2,1.2,1.3  <(sort test.1) <(sort test.2)12 0.009 Jane 1615 0.392 Clarke 7823 1.2E-5 Joann 3124 0.738 Kristen 90$