I have two tab separated files (please see the examples below):
Java RAJ
PERL ALEX
PYTHON MAurice
(and so on)
ALEX 3.4
SAM 8.9
PEPPER 9.0
Now, if for instance say ALEX is also found in file 2 (it is not for sure that ALEX will be found) I should have a third file looking like this:
PERL ALEX 3.4
The code should check for all the values in column 2 of file 1 in file2.
Any suggestions for a bash script?
You want to use join
for that. First you need to sort according to join field though:
join -1 2 -2 1 <(sort +1 -2 file1) <(sort +0 -1 file2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With