How do I extract the domain name from a url using bash? like: http://example.com/ to example.com must work for any tld, not just .com
$ URI="http://user:pw@example.com:80/" $ echo $URI | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/' example.com
see http://en.wikipedia.org/wiki/URI_scheme