Say your IP's are in a file called ips
spread over different fields over different lines and the field separator is the default one, namely a space.
Example:
cat ips
223.247.184.95 223.247.186.243 223.247.208.16 223.247.209.139 223.84.128.24
223.84.159.214* 223.84.159.245*
then for
Unsorted IPs file: the following awk code
cat ips | awk '{for(i=1;i<=NF;i++){split($i,a,".");k=a[1]"."a[2]"."a[3];h[k]=h[k]" "$i}}END{for(k in h)printf(k": "h[k]"\n")}'
gives you a hash table of the different C domains:
223.247.184: 223.247.184.95
223.247.186: 223.247.186.243
223.84.159: 223.84.159.214* 223.84.159.245*
223.84.128: 223.84.128.24
223.247.208: 223.247.208.16
223.247.209: 223.247.209.139
Sorted IPs file: If the file containing your IP has been previously sorted, then there is a more efficient and faster one-liner
cat ips| awk '{for(i=1;i<=NF;i++){split($i,a,".");cn=a[1]"."a[2]"."a[3]; if(cn != c){c=cn;printf("\n"c": ")};printf($i" ")}}END{printf("\n")}'
giving you as well
223.247.184: 223.247.184.95
223.247.186: 223.247.186.243
223.247.208: 223.247.208.16
223.247.209: 223.247.209.139
223.84.128: 223.84.128.24
223.84.159: 223.84.159.214* 223.84.159.245*