Join will help if the files are sorted. Also you have in your file1 rows, that have not 4 fields/columns but only 3.
Also in your desired output your first line looks like:
Quote:
SUPHYA 0002522 122 JACOB a1232
but in your input file1, the only line that has "a1232" in it, has the key "0002522". The line of file2 that matches and contains "SUPHYA", has "0002533" as key... so how should that work. The desired output doesn't not work with the input files. I see no logic behind the output or maybe it is screwed up because it is not in [ code ] [ /code ] tags, idk.
If there is no match, you still want the line of file2 printed out, it seems, sometimes, not always.
Maybe you are better off using awk and to check if $NF of file1 matches with $2 or $NF of file2.
Something is screwed up in the desired output file, at least for me.
EDIT: Also in the attached file there is only the content of file2 as far as I can see.
@prakashreddy
He used join already and without sorting it won't work anyway. Also a simple paste will help nothing to get that desired output. Paste can't join on fields. Or maybe you can show how to do that.