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
You can use simple AWK way to extract the domain name as follows:
echo http://example.com/index.php | awk -F[/:] '{print $4}'
OUTPUT: example.com
example.com
:-)
2.1m questions
2.1m answers
60 comments
57.0k users