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
With Ruby you can use the Domainatrix library / gem
http://www.pauldix.net/2009/12/parse-domains-from-urls-easily-with-domainatrix.html
require 'rubygems' require 'domainatrix' s = 'http://www.champa.kku.ac.th/dir1/dir2/file?option1&option2' url = Domainatrix.parse(s) url.domain => "kku"
great tool! :-)