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 c
First sort both files. Then use join to join on the first field of both files. You also need to pipe the output through sed if you want to remove the space and thus convert a a into aa. This is shown below:
$ join -t " " -1 1 -2 1 -a 1 -a 2 <(sort file1) <(sort file2) | sed 's/ \([a-z]\) / \1/g'
1 aa
2 b
3 c
4 d
5 e
6 ff
7 g
8 h