I am looking for a way to retrieve the main domain (naked) from a random domain/subdomain. What I am looking for is not a sed or awk command (as the domain is random) but some string with dig, host or nslookup that can actually show the naked domain. Any suggestion?
Example:
from www.bbc.co.uk -> bbc.co.uk
from www.google.com -> google.com
from subdomain.google.co.uk -> google.co.uk
from subdomain.ofasubdomain.google.com.au -> google.com.au