If it's only the first field to match against:
function loader(fname,fld, barra,x,z) {
if (fld ~ /[0-9]/) {
while ((getline < fname) > 0) {
barra[x++] = $fld
}
close(fname)
return rebuild(barra,x)
} else {
while ((getline < fname) > 0) {
barra[x++] = $0
}
close(fname)
return rebuild(barra,x)
}
return 1
}
function rebuild(a,b, cnt,ret) {
for (cnt=1 ; cnt <= b ; cnt++) {
ret = length(ret) < 1 ? a[cnt]" \n" : ret" "a[cnt]" \n"
}
return ret
}
BEGIN {
z = split(loader(file1,1),arr1,"\n"

}
{
for (x = 1 ; x <= z ; x++) {
if ($0 ~ arr1[x]) {
print $0, "matched->Additonal::", arr1[x]
}
}
}' file2
There's also this which you are welcome to adapt:
function qsortM(array1,array2,min1,max1,min2,max2,matches) {
if (min1 >= max1 || min2 > max2) {
return
}
m = min1 ; e = min2
for (i = (min1 + 1) ; i <= max1 ; i++) {
for (x = (min2 + 1) ; x <= max2 ; x++) {
if (array1
== array2[x] && length(array1) > 0) {
print "Match", array1"="array2[x],"at",i, "and", x
matches++
}
}
}
qsortM(array1,array2,min1,(m - 1),min2,(e - 1),matches)
qsortM(array1,array2,(m + 1),max1,(e + 1),max2,matches)
return matches
}
function _elems(arr, i,k) {
for (i in arr) {
k++
}
return k
}
function parray(arr,u, f) {
print "Max=", u
while (f <= u) {
f++
if (arr[f] == ""
{
continue
} else {
print arr[f]
}
}
}
BEGIN {
srand()
cn = 0
for (z = int(1 + rand() * 125) ; z < 125 ; z += 2) {
#print z
a[cn++] = z * 12
}
cn = 0
for (p = int(1 + rand() * 125) ; p < 125 ; p += 2) {
#print p
d[cn++] = p * 12
}
#print "Elements in a:", cnt1 = _elems(a)
#print "Elements in d:", cnt2 = _elems(d)
#parray(a,cnt1)
#parray(d,cnt2)
print "Matches found" , mat = qsortM(a,d,1,_elems(a),1,_elems(d),0)
}
I'm not explaining it though..I'm tired from just writing the nonsense.