Let’s say I have two text files that I need to extract data out of. The text of the two files is as follows:
File 1:
1name - randomemail@email.com
2Name - superrandomemail@email.com
3Name - 123random@email.com
4Name - random123@email.com
File 2:
email.com
email.com
email.com
anotherwebsite.com
File 2 is File 1’s list of domain names, extracted from the email addresses.
These are not the same domain names by any means, and are quite random.
How can I get the results of the domain names that match File 2 from File 1?
Thank you in advance!
Assuming that order does not matter,
should do the trick. (This works because of a little-known fact: the
-Foption togrepdoesn’t just mean “match this fixed string,” it means “match any of these newline-separated fixed strings.”)