Hi,
I have two files one (abc.txt) is having approx 28k records and another (bcd.txt) on is having 112k records, the length of each files are varried.
I am trying to look up abc.txt file with bcd.txt based on length, where ever abc.txt records are matching with bcd.txt I am successful match the records with bcd, but I am unable to fetch the records which are not matching with bcd.txt.
abc.txt
bcd.txt
I want the mismatch in each file are as below:
below is my script which I tried for matching of the records, but its is taking almost 5 hours, and next I am unable to find the mismatch records for both the files.
Please help me on this, this will save a lot of manual work at my end.
Regards,
Ram
I have two files one (abc.txt) is having approx 28k records and another (bcd.txt) on is having 112k records, the length of each files are varried.
I am trying to look up abc.txt file with bcd.txt based on length, where ever abc.txt records are matching with bcd.txt I am successful match the records with bcd, but I am unable to fetch the records which are not matching with bcd.txt.
abc.txt
Code:
191
120
122
123
1234
1245
123456
1890
Code:
120
1201
1203
121
122
1224
12345
123
199
Code:
abc.txt matches with bcd.txt
120
1201
1203
122
1224
123
12345
abc.txt not matches with bcd.txt
191
1890
1245
bcd.txt not matches with abc.txt
199
Code:
awk -F"," 'BEGIN{OFS=","}
{
if(NR==FNR){
a[FNR]=$0;max=FNR;Next}
if(NR!=FNR)
{
if (FNR==1) print $0;
for ( i=1;i<=max;i++)
{
tmp = a[i];
len = length(tmp);
if(substr($1,1,len) ==tmp)
{print $0;}
} #End For
} #End if
}' abc.txt bcd.txt > abc_matches_bcd.txt;
Regards,
Ram