I have following 2 files:
File1: Fields (X,A,B) File is sorted on the basis of the fields A and B asc
LLLLLL AAAAAA 00000000000000000000000000
LLLLLL AAAAAA 11111111111111111111111111
MMMMMM AAAAAA 11111111111111111111111111
OOOOOO BBBBBB 00000000000000000000000000
PPPPPP BBBBBB 33333333333333333333333333
NNNNNN CCCCCC 00000000000000000000000000
LLLLLL AAAAAA 11111111111111111111111111
MMMMMM AAAAAA 11111111111111111111111111
OOOOOO BBBBBB 00000000000000000000000000
PPPPPP BBBBBB 33333333333333333333333333
NNNNNN CCCCCC 00000000000000000000000000
File2: Fields (A,B,Z) File is sorted on the basis of the fields A and B asc
AAAAAA 11111111111111111111111111 DATA01
AAAAAA 11111111111111111111111111 DATA02
AAAAAA 11111111111111111111111111 DATA03
AAAAAA 22222222222222222222222222 DATA04
BBBBBB 00000000000000000000000000 DATA05
BBBBBB 00000000000000000000000000 DATA06
BBBBBB 11111111111111111111111111 DATA07
BBBBBB 22222222222222222222222222 DATA08
CCCCCC 00000000000000000000000000 DATA09
CCCCCC 11111111111111111111111111 DATA11
CCCCCC 22222222222222222222222222 DATA12
AAAAAA 11111111111111111111111111 DATA02
AAAAAA 11111111111111111111111111 DATA03
AAAAAA 22222222222222222222222222 DATA04
BBBBBB 00000000000000000000000000 DATA05
BBBBBB 00000000000000000000000000 DATA06
BBBBBB 11111111111111111111111111 DATA07
BBBBBB 22222222222222222222222222 DATA08
CCCCCC 00000000000000000000000000 DATA09
CCCCCC 11111111111111111111111111 DATA11
CCCCCC 22222222222222222222222222 DATA12
Final output file expected as:
LLLLLL AAAAAA 11111111111111111111111111
MMMMMM AAAAAA 11111111111111111111111111
OOOOOO BBBBBB 00000000000000000000000000
NNNNNN CCCCCC 00000000000000000000000000
MMMMMM AAAAAA 11111111111111111111111111
OOOOOO BBBBBB 00000000000000000000000000
NNNNNN CCCCCC 00000000000000000000000000
Now I need to get an output file with only the details from the file1 which have a matching values for the fields A and B from both the files. Please note that both the files can have duplicates on the joining fields. I will need to have the duplicates retained in the output file from file1. I tried a lot of combinations, but am not able to get to the final results due to the duplicates present in both the input files. Can someone please help me out here?