Comparing two files using four fields

[LEFT]I want to compare File1 and File2 (Separated by spaces) using four fields (Column 1,2,4,5).
Logic: If column 1 and 2 of File1 and File2 match exactly and if the File2 has the same characters as any of the characters present in column 4 and 5 of file1 then those lines of file1 and file2 are concatenated and redirected as output.
File1:
[/LEFT]
s2/80 20 . A T 86 N=2 F=5;U=4
s2/20 10 . G T 90 N=2 F=5;U=4
s2/90 60 . C G 30 N=2 F=5;U=4
s2/40 70 . A G 80 N=2 F=5;U=4

File2:

s2/90 60 . G G 97 N=2 F=5;U=4
s2/80 20 . A A 20 N=2 F=5;U=4
s2/15 11 . A A 22 N=2 F=5;U=4
s2/90 21 . C C 82 N=2 F=5;U=4
s2/20 10 . G G 99 N=2 F=5;U=4
s2/40 70 . A G 70 N=2 F=5;U=4
s2/80 10 . T G 11 N=2 F=5;U=4
s2/90 60 . G T 55 N=2 F=5;U=4

Expected Output:
s2/80 20 . A T 86 N=2 F=5;U=4 s2/80 20 . A A 20 N=2 F=5;U=4
s2/20 10 . G T 90 N=2 F=5;U=4 s2/20 10 . G G 99 N=2 F=5;U=4
s2/90 60 . C G 30 N=2 F=5;U=4 s2/90 60 . G G 97 N=2 F=5;U=4

I am new in the field and I would appreciate your help.

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Continue here:

Thank You.

The UNIX and Linux Forums.

1 Like