Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract domain name from url?

Tags:

regex

bash

url

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

like image 572
Ben Smith Avatar asked Mar 23 '10 02:03

Ben Smith


People also ask

How do you find the domain name of a website?

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.

How do I extract a domain from a URL in Google Sheets?

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.

How do I find my domain name and URL?

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.


1 Answers

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

:-)

like image 180
Soj Avatar answered Sep 18 '22 13:09

Soj