I have a file which looks like this:
This is a space-separated file. The strings appearing before and after the space is made up of smaller substrings, namely b_1_1_3- , k_3_4_6-, b_12_4_5- etc. I have to check how many of the smaller substrings on the Left side of the space are contained in the string appearing on right side of the space.
For eg: The 1st line has the substring a_12_3_5- which is present in the string on the right hand side. The 2nd line shows exact match with the right side. 3rd line however shows that there is only one substring on the left side (c_3_4_6-) which is contained in the string on the right side. 4th and 5th lines represent cases wherein no substring on left side is contained in the string on right side. Next line shows that there is only one substring (b_1_1_7-) that is contained in the string on right side. The last line shows that there are 2 substrings b_1_1_7- and f_3_8_7- which are contained in the string on the right hand side.
Thus effectively, I want to see how many of the substrings on the left hand side are contained in the string on the right hand side. I am trying to get the output in the following manner, such that each line in my file is appended with three numbers i.e number of substrings in left side, number of substrings in right side, no.of substrings on left side that are contained in the right side.
a_12_3_5- k_3_4_6-a_12_3_5- 1 2 1
q_1_5_7_9- q_1_5_7_9- 1 1 1
a_9_4_5-c_3_4_6- c_3_4_6-r_4_5_7- 2 2 1
b_1_1_3- v_1_5_7- 1 1 0
d_12_4_5-e_4_5_6- g_5_6_7-d_6_8_6- 2 2 0
b_1_1_7-f_3_8_7_8-d_4_1_4- d_4_1_5-b_1_1_7-f_3_8_3- 3 3 1
b_1_1_7-f_3_8_7_8-d_4_1_4- e_3_3_1-f_3_8_7-f_21_3_1-b_1_1_7-a_1_1_1- 3
+ 5 2
I have so far been able to get the above output , but cant seem to get upto the last portion of the line. I have tried using os and also index functions. but cant seem to get ahead.