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
Use ICANN Lookup The Internet Corporation for Assigned Names and Numbers (ICANN) is a non-profit organization that collects domain information. Use the ICANN Lookup tool to find your domain host. Go to lookup.icann.org. In the search field, enter your domain name and click Lookup.
The =REGEXREPLACE() function is built-in Google Sheets and it extracts domains from URLs. What's great about is it's only a simple line of code that you can paste into your cell. The function is not super technical and you can change it any way you see fit.
Whereas domain name is a part of URL which is a user-friendly form of IP address. We use the URL for identifying a particular web page. For example, http://www.abzwebpedia.com/index.html is a complete URL. “abzwebpedia.com” is the domain name.
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
:-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With