How to join 2 text files using bash scripting?

Hi Guys,

I want to combine 2 files and and put together in 1 file [ only 2 fields ($4 and $5 in FILE A, $2 and $3 in FILE B) are the common thing between the two files]. See below desired output. Any help will be much appreciated.

FILE A

X  2134  101L  12345.00   22222.00    1  10
X  2134  101L  12345.00   22222.00  11  20
X  2134  101L  12345.00   22222.00  21  30
X  2134  111L  77777.00   22222.00    1  10
X  2134  111L  77777.00   22222.00  11  20
X  2134  111L  77777.00   22222.00  21  30
X  2134  121L  56347.00   46678.00    1  10
X  2134  121L  56347.00   46678.00  11  20
X  2134  121L  56347.00   46678.00  21  30
........

FILE B

3333 12345  22222  54367.05  34765.05
3333 34567  12235  54298.05  34568.05
3333 77777  22222  52765.05  32567.05
3333 55555  11111   52875.05  36547.05
3333 56347  46678  53789.05  34566.05
........

_______________________________
RESULT

3333 2134   10   12345 22222 54367.05 34765.05
3333 NA     NA 34567 12235 54298.05 34568.05
3333 2134   11    77777 22222 52765.05 32567.05
3333 NA     NA  55555 11111  52875.05 36547.05
3333 2134   12 56347 46678 53789.05 34566.05
.......

Thanks in advance!:b:

Hello H.R,

Welcome to forums, please use code tags for complete Input_file and sample outputs into posts as per forums rules. Here are some points which are not clear into your request.
I- Number of lines into filea and fileb are NOT same, so how comparison should happen?
II- IN case it should be by filea's $4 and $5 and fileb's $2 and $3 (as per your post) then also there is a question, let's say we have following scenario where same values of $4 and $5 have more than one values into it then which value we should print?
It is advisable to please describe your requirement little more with sample Input_file and expected Output_file. Anyways based on few wild assumptions following you could take as a startup for this problem.

awk 'FNR==NR{sub(/\..*/,X,$4);sub(/\..*/,X,$5);A[$4 FS $5]=$2 FS $NF;next} {$2=($2 FS $3) in A?A[$2 FS $3]:"NA NA"} 1' filea fileb

Output will be as follows.

3333 2134 30 22222 54367.05 34765.05
3333 NA NA 12235 54298.05 34568.05
3333 2134 30 22222 52765.05 32567.05
3333 NA NA 11111 52875.05 36547.05
3333 2134 30 46678 53789.05 34566.05

Please get back to us in case of any queries on same.

Thanks,
R. Singh

Thank you Mr R. Singh for your reply,

I attached one picture, it will describe well my requirement, thanks in advance

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

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

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.