gawk '	BEGIN {FS = "."};
	{for (feld = NF; feld>=1; feld--) {
		if (feld!=1)
			printf("%s.",tolower($feld))
		else
			printf("%s\n",tolower($feld))
	}
}' domains.junk | sort | uniq > domains.inv.s.u
#
# this sorts the entries as follows:
# domain . subdomain . subsubdomain etc. hostname 
#
gawk ' BEGIN {previous_line = "deadbeef"};
	{if ( $1 !~ previous_line) {
#	{if ( previous_line !~ $1 ) {
		previous_line = $1
		print $1
	}
}' domains.inv.s.u > domains.inv.pruned
#
# This prunes the tree we've just generated (if aol.com is an entry, we don't need mail.aol.com)
#
gawk '  BEGIN {FS = "."};
        {for (feld = NF; feld>=1; feld--) {
                if (feld!=1)
                        printf("%s.",tolower($feld))
                else
                        printf("%s\n",tolower($feld))
        }
}' domains.inv.pruned | sort | uniq > domains.junk.pruned
rm domains.inv.s.u domains.inv.pruned
#
# This restores the normal order of the entries 
#

