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
:-)
1.4m articles
1.4m replys
5 comments
57.0k users