The problem is not clear. At least to somebody like me who knows little about IP addresses. I assumed:

the "keys" are in lines with four fields, in the second field, before the first (and only?) "::"; the lines to rewrite have two fields, the key being before one of the ":" in the second field (I consider prefixes of growing size).


Here is a solution with AWK:
#!/usr/bin/awk -f
BEGIN {
    while (getline < ARGV[1])
        if (NF == 4)
        {
            split($2, a, "::")
            m[a[1]] = $2 " " $3 " " $4
        }
}
NF == 2 {
    n = split($2, a, ":")
    k = a[1]
for (i = 1; !(k in m) && ++i

Reply via email to