What I want to do is something like below. I have a URL, say http://www.google.com/one/two/three
I need to extract the main domain name "www.google.com", to feed it to nslookup (As nslookup/dig does not seem to work with full URL) and then replace the URL with resolved IP address.e.g.
$ echo "http://www.google.com/one/two/three" | sed "s/<pattern>//g"
$ www.google.com
The problem is that "http://" may not always be there. And then
$ echo "http://www.google.com/one/two/three" | sed "s/<pattern>//g"
$ http://11.22.33.44/one/two/three
Can anyone provide any related link or related examples ?