extracting columns from 2 files

Hello,

I have 2 files file1 & file2

[File1 content] =
a1 b1
a2 b2
a3 b3
...

[File2 content] =
c1 d1
c2 d2
c3 d3
...

I need to compare if b(i)=c(j) . i,j=1,2,3,4,...

If yes, right a(i) d(j) in output file3 per line

Thankx to help

Try,

$ paste -d' ' file1 file2 | awk '$2 == $3{ print $1, $4 }'