0

Let say I have something like:

url=www.myurl.com
url2=myotherurl.com
url3=wwww3.anotherurl.com

❯ echo "$url \n$url2\n$url3" | sed 's/^www.//'
myurl.com 
myotherurl.com
3.anotherurl.com

echo "$url \n$url2\n$url3" | sed 's/^www\d*\.//'
myurl.com 
myotherurl.com
wwww3.anotherurl.com

I thought \d* is 0 or more digits

What I a want is to just get host.com no matter if there is a www or www3 or if there no www used.

Thanks for you help

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
sauce1173
  • 65
  • 5
  • what about `https://www3.host.com` ? Does your pattern have to handle those cases as well ? – Aserre Jul 08 '22 at 08:50
  • That would be great too. It might help to make my script shorter But if thats too much it does need to go there. I can just do it in to parts – sauce1173 Jul 08 '22 at 09:25
  • 1
    To remove the `http://` part, you can have a look at [this question](https://stackoverflow.com/questions/2497215/how-to-extract-domain-name-from-url) – Aserre Jul 08 '22 at 12:49

0 Answers0