Joining two files second column in first file and first column in second file

Dear all

I am having two list files , i want join these two file according second column in first file and first column in second file

1st file

1       A
2       R
3       B
4       s
5       S

2 nd file

A       m
S       n
B       i
s       L
R       f

resultent output should be

1 A m
2 R f
3 B i
4 s L
5 S n

could u pls help

awk 'NR==FNR{a[$1]=$2;next}{print $1, $2, a[$2]}' file2 file1
1 Like
perl -lane 'open I, "< file2";
for (<I>) {
    chomp; @x = split /\s+/;
    ($F[1] eq $x[0]) && print "$F[0] $F[1] $x[1]";
}; close I' file1
1 Like