0

Removing character in list of strings If I have a list of strings such as: ( each url in new line)

"https://www.test.com/test.html"
"https://www.a.com/y.html"
"https://www.sdf.com/zs.html"
"https://www.csc.com/xxxx.com/"

What should I do to get this output?

www.test.com
www.a.com
www.sdf.com
www.csc.com
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
  • You should read up on `grep` and `regular expressions`. – tink Feb 15 '19 at 17:34
  • 1
    Possible duplicate of [How to extract domain name from url?](https://stackoverflow.com/q/2497215/608639), [How do I extract the domain out of an URL?](https://stackoverflow.com/q/827024/608639), [Parse url in shell script](https://stackoverflow.com/q/6174220/608639) and friends. – jww Feb 15 '19 at 17:38
  • *"What should I do to get this output?"* - You should search for similar questions asked many times before instead of dumping it here. It is unfortunate I am out of downvotes... – jww Feb 15 '19 at 17:40
  • In this case "awk -F/ '{print $3}' file" would work well. – Claes Wikner Feb 15 '19 at 19:50

1 Answers1

0

With cut :

cut -d'/' -f3 infile
ctac_
  • 2,413
  • 2
  • 7
  • 17