revdom 245 B

1234567891011
  1. #!/bin/awk -f
  2. # reverse whilelist domains
  3. function rev(s, i, n, ndom, dom) {
  4. n = split(s, dom, ".")
  5. ndom = dom[n]
  6. for (i = n-1; i >= 1; i--)
  7. ndom = ndom "." dom[i]
  8. return ndom
  9. }
  10. NF == 1 { print }
  11. NF == 2 { printf "%s %s\n", $1, rev($2) }