I have an alphabetically sorted file names.txt
containing names:
Dio Brando
Erina Pendleton
Jonathan Joestar
Mario Zeppeli
....
and a folder containing files:
a1.txt
a2.txt
....
zn.txt
each having lines with Name: phone number
. Assuming recursion goes though files alphabetically, I'd like to grep each line from names.txt
and switch to the next name whenever it fails to find a match in the next one.
For example: I grep for "Dio Brando" and it reaches in file, say, D2.txt
following lines:
Dio Brando: phone number 1
Dio Brando: phone number 2
Dio Brando: phone number 3
<not Dio Brando>: phone number 1
When I hit the <not Dio Brando> line, I want it to start searching for "Erina Pendleton" where it left off (from D2.txt
onward). It's guarantied to find at least one match, and when it fails after that, it should switch to "Jonathan Joestar" etc. Is it possible without some serious scripting?
If resuming with the next name is not doable, just performing grep on each line through the whole folder will do.