I have a file containing population information for a bunch of towns. I have another file that is a list of the names of a subset of those towns. I want to select the population information from the first file using the second file. How would I do this?
Examples:
File 1: ma-towns.txt
Acton Town Middlesex Open town meeting 21,924 1735
Acushnet Town Bristol Open town meeting 10,303 1860
Adams Town Berkshire Representative town meeting 8,485 1778
Agawam City[4] Hampden Mayor-council 28,438 1855
Alford Town Berkshire Open town meeting 494 1773
Amesbury City Essex Mayor-council 16,283 1668
Amherst Town Hampshire Representative town meeting 37,819 1775
File 2: town-list.txt
Acton
Adams
Agawam
Desired output would be
Acton Town Middlesex Open town meeting 21,924 1735
Adams Town Berkshire Representative town meeting 8,485 1778
Agawam City[4] Hampden Mayor-council 28,438 1855
Basically, as said generally, extract the line if it contains the string in one of the lines of file 2.