#!/bin/rc
# whitewash - sort /mail/grey/whitelist by reversed domain name
rfork en
fn revdom {
awk '
{
printf("%-24s", $1);
n = split($2, a, ".");
if (n > 0){
printf(" %s", a[n]);
for (i = n-1; i > 0; i--)
printf(".%s", a[i]);
}
if (NF >= 3)
printf("\t\t");
for (i = 3; i <= NF; i++)
printf(" %s", $i);
printf("\n");
}
' $*
}
{ grep -v '^[ \t]*$' $* | revdom | sort -f -b +1 | revdom ; echo '' }
|