我有两个文件,一个是包含 IP 和主机信息的“主列表”,另一个是动态填充 IP 和用户代理字符串。请参见下面的示例。
示例文件 1:
24.143.206.32 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
66.39.66.63 Dalvik/1.6.0 (Linux; U; Android 4.2.1; Nexus 7 Build/JOP40D)
示例文件 2:
24.143.206.32 # New Host US,city,44.8824996948,-99.6440963745
66.39.66.63 # New Host US,city,44.8824996948,-99.6440963745
and on and on
我需要找到两个 AND 输出匹配与 BOTH 的尾随信息之间的 IP 匹配。
24.143.206.32 Browser: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) LOCATION: New Host US,city,44.8824996948,-99.6440963745
66.39.66.63 Browser: Dalvik/1.6.0 (Linux; U; Android 4.2.1; Nexus 7 Build/JOP40D) LOCATION: New Host US,city,44.8824996948,-99.6440963745
目前我正在使用它进行 IP 匹配:
awk 'FNR==NR{ a[$1]=$0;next } ($1 in a)' file1 file2 > matchesfile
我一遍又一遍地尝试,只是无法获得我需要的所有信息。你能提供任何帮助还是这太复杂了?我不确定这个方向。