These "trivial" AWK programs are presently beyond my ken. Way too compact for
me at this hour.
In the meantime I started with this script:
awk '{print $2}' 'File01.txt' | sort | uniq -c > TempTQ01.txt ;
awk '{print $2, $1}' 'TempTQ01.txt' | sort -nrk 2 > TempTQ02.txt
where File01.txt is the original 370,000 row file, albeit truncated to
exclude the 38,000 rows
that I've already filled in and also all the five-column resolved hostname
rows, leaving only
Type A and Type B IPv6 address data in 347,000 rows. Type B are the keyed
IPv6 addresses and
the number of occurrences; Type B are CIDR blocks distinguishable by their
'/' characters. We
don't need to use the Type B data except as a reality check.
What remains is to print all the $1 columns of the IPv6 rows that match the
first IPv6 key in
the TempTQ02 list, plus the $2, $3, and $4 columns of the corresponding Type
B row to make C
rows (Column $2 of TempTQ02.txt) of filled-in data, then move on to the next
IPv6 key in the
TempTQ02.txt file. The largest number of occurrences (55,000) exist in one
contiguous group
of 55,000 rows, one of which contains the IPv6 key address and its three
columns of asn-query
data. The occurrences data (C) are also needed only as a reality check.
I also meddled with the asn-query source code
(https://svn.nmap.org/nmap/scripts/asn-query.nse)
and learned how to store & retrieve it as a program file which returns the
same data for those
eight IPv6 addresses given above, plus the asn-query data. Alas, further
meddling (beyond just
putting something else between the quotes of "See the result for %s") has
been unproductive.
George Langford