Q:

Using Sed to pull out base URL of full website

I'm looking to cat a file containing something like this:
    http://www.site1.com/d23bdbd0fbc517d34, r N 4
    https://www.site2.com/file/d23bdbd0fbc517d34, X
    http://www.site3.com/file/d23bdbd0fbc517d34
    https://www.site4.edu/site/d23bdbd0fbc517d34

and I need use sed to get this kind of output:
    www.site1.com
    www.site2.com
    www.site3.com
    www.site4.edu

Help!   I can't get it fully working right.   Technically I'm using sed.exe for Windows but it's probably very similar. 

A:

$ cat file.txt
    http://www.site1.com/d23bdbd0fbc517d34, r N 4
    https://www.site2.com/file/d23bdbd0fbc517d34, X
    http://www.site3.com/file/d23bdbd0fbc517d34
    https://www.site4.edu/site/d23bdbd0fbc517d34
$ sed -r 's@.*//([^ /]+).*@\1@g' file.txt
www.site1.com
www.site2.com
www.site3.com
www.site4.edu

If you don't have -r switch :
sed 's@.*//\([^ /]\+\)[/ ].*@\1@g' file.txt

Moreover, under windows IIRC, use double-quotes instead of single-quotes. 
So maybe :
sed.exe "s@.*//\([^ /]\+\)[/ ].*@\1@g" file.txt

