file1, containing IP section information, has about 10,000 rows, and file2 containing an IP and other information, has 30,000 rows and is growing.
Now I want to fetch the "location" field from file1 based on the IP field from file2, and combine "location" field with "information" field from these two files, I know I can convert all this IPs to an unsinged integer, and compare the IP field from file2 against the IP section in file1, but this kind of comparison is rather inefficient, I need a FAST algorithm to do this, AWK would be favored.
A straightforward approach using awk would be to ( if second field from file1 is not being used ) create an associative array with field1 and field3, then parse through the second file and check if the entry in the second file is there in the associative array, if there print out the value from the associative array.
Sorry, I didn't elaborate on my problem. field1 and field2 from file1 are Legal IP addresses forming a section(e.g. from 111.111.111.0 to 111.111.111.255). I want to get the 'location' filed from file1 given an IP address(the first field from file2) falling within the section.
The IP sections in file1 are sorted.