Search strings from array in second file

I have a file search_strings.txt filled with search strings which have a blank in between and look like this:

S. g. Erh.
o. J.
v. d. Chijs
g. Ehr.

I would like to search the strings in the second given Textfile.txt and it shall return the column number.

Can anybody help with the correct code or optimize the code?

awk 'NR==FNR{a[$0]++; next}
              {for(i in a); t=match($0, i); if(t) {l=length(i) $0=substr($0,t+l) print i, $1 next;}}
               }' search_strings.txt textfile.txt

Are those items in search_strings.txt all suposed to be adjacent fields? Or separate fields? Looks like separate fields.

Please give sample input file and a sample of desired output from that sample input file.

Search pattern: "v. d. Chijs"
This is the text: "In the meantime v. d. Chijs found the text"

The search pattern ist "v. d. Chijs" and what is needed is the search pattern plus the column in with the string is found.

$ cat textfile.txt
In the meantime v. d. Chijs found the text

$ awk 'NR==FNR{a[$0]++; next}
     { for(i in a) 
         if ($0~i) 
             { sub(i ".*", "",$0); print i, NF+1}
     }' search_strings.txt textfile.txt

v. d. Chijs 4
1 Like