Infile1:
1 a
3 c
4 d
6 f
Infile2:
1 a
2 b
5 e
6 f
7 g
8 h
How do I join these files with the unix join command to get this output:
1 aa
2 b
3 c
4 d
5 e
6 ff
7 g
8 h
Dogbanes answer worked but…
when I apply dogbanes answer on this file:
27 27
28 22
29 37
30 15
31 21
32 13
33 18
34 24
and this:
27 7
28 13
29 6
30 12
31 30
32 5
33 10
34 28
They don’t join:
27 27
27 7
28 13
28 22
29 37
29 6
30 12
30 15
31 21
31 30
32 13
32 5
33 10
33 18
34 24
34 28
The second scenario is tab delimited so I used -t \t
First
sortboth files. Then usejointo join on the first field of both files. You also need to pipe the output throughsedif you want to remove the space and thus converta aintoaa. This is shown below: