I have two different files with two columns each.
file1.txt
DevId Group
aaa A
bbb B
file2.txt
Group RefId
A 111-222-333
B 444-555-666
I need only need DevId and its corresponding RefId.
Required Output
DevId RefId
aaa 111-222-333
bbb 444-555-666
I tried using this syntax but I can't get it correctly.
awk -F, -v OFS=, 'NR==FNR{a[$1]=$2;next}{print a[$2],$1}' file2.txt file1.txt
I hope someone could help me.