0

I have data that looks like this:

<b><a href="/title/tt3645068/"
<b><a href="/title/tt2741602/"
- <a href="/title/tt3173408/"
<b><a href="/title/tt1442464/"
- <a href="/title/tt2605802/"
<b><a href="/title/tt0103569/"

I am trying to replace everything before /title and replace it with https://imdb.com

I tried something like this but it doesn't work:

sed "s/^.*href='/https\:\/\/www\.imdb\.com/"

Can you please help me correct this error?

Nic3500
  • 8,144
  • 10
  • 29
  • 40
vishal_P
  • 51
  • 2
  • 7
  • `sed -e 's@^.*/title@https://imdb.com@'` -- beyond the notes in the linked questions about making handling of slashes sane, also note that `'` and `"` are two different characters, and putting one in a regex will not match the other. – Charles Duffy Apr 11 '22 at 00:39

1 Answers1

1
> sed 's/.*\(\/title.*\)/https:\/\/www.imdb.com\/\1/' data
https://www.imdb.com//title/tt3645068/"
https://www.imdb.com//title/tt2741602/"
https://www.imdb.com//title/tt3173408/"
https://www.imdb.com//title/tt1442464/"
https://www.imdb.com//title/tt2605802/"
https://www.imdb.com//title/tt0103569/"
Christian Fritz
  • 20,641
  • 3
  • 42
  • 71
  • 1
    `sed '...' data`, avoiding the `cat`, will allow better error messages and involve less overhead. (The overhead reduction can likewise be accomplished by `sed '...' – Charles Duffy Apr 11 '22 at 00:50