I have two TXT files , 1.txt has 11,000 IPs and 2.txt has 1 Million IPs. I want to match 1.txt against 2.txt ( 1 million IPs) and get the matching ones.
#1.txt
1,1.1.1.1
2,2.2.2.2
3,3.3.3.3
.........
#2.txt
51.51.6.10
12.10.25.16
1.3.50.55
0.0.0.0
6.6.6.6
1.1.1.1
2.2.2.2
5.5.5.5
6.6.6.6
7.7.7.7
20.200.100.30
Like wise 1 Million lines of IPs.......
Matching Result :
1,1.1.1.1
2,2.2.2.2
I tried doing
awk -F, 'NR==FNR{a[$0];next}($2 in a)' 2.txt 1.txt
,It gives me the exact answer for the smaller subset(Test Runs). But checking against the original files 11,000 against 1 Million IPs,It's returning me all the IPs which is in1.txt
.Tried
sed -n -f <(sed 's|.*|/,&$/p|' 2.txt) 1.txt
, Process is automatically killed.Tried,
comm -23 1.txt 2.txt > 3.txt
,Again returning all the IPs from 1.txt.
Not sure with the issue on where i'm making mistakes / matching against 1 million IPs is not possible using sed , awk , comm or any ? Can some one help me on suggesting what will be the issue ?
Reference Used : http://stackoverflow.com/questions/4366533/remove-lines-from-file-which-appear-in-another-file