I'm sure this is super simple but I can't think of a way to do it. I have File1 and File2 (below) and I need to join based off the letter in the alphabet, but also print out the lines that have no match.
File1:
a james
b mike
c joe
d john
e nick
f chris
File 2
a 10 20 30 40
b 11 12 13 14
d 20 30 40 50
f 15 16 17 18
I want the output file to say
a james 10 20 30 40
b mike 11 12 13 14
c joe
d john 20 30 40 50
e nick
f chris 15 16 17 18
I'm supposed to use one line only. I tried:
join file1 file2 > file3
but that didn't print the lines that don't have a match.
If you do join -a1 file1 file2 > file3
that will work because it makes it a left outer join. join
on its own is an inner join.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.