sed special characters issue

Hi I'm trying to replace string1 by string2 in file homepage.htm as follows but is not working. Please Help:

sed

sed -i "s@'://your server name:port/test/owa'@'://11.22.33.44:5555/pls/SAMPLE'@g" homepage.htm

Where,

String1

://your server name:port/test/owa

String2

://11.22.33.44:5555/pls/SAMPLE

homepage.htm file:

<meta http-equiv="refresh" content="0;URL=http://your server name:port/test/owa/process.show_menu?name=homepage">

---------- Post updated at 06:23 PM ---------- Previous update was at 06:22 PM ----------

I used character @ instead / because string to replace contains character /.

The sed pattern contains single quotes but the data in the htm file does not contain any.

Regards,
Alister

1 Like

See if this will work for you:

$ v="://your server name:port/test/owa"
$ rpl_test="://11.22.33.44:5555/pls/SAMPLE"
$ echo "$v" | sed "p;s?://your server name:port/test/owa?$rpl_test?"
://your server name:port/test/owa
://11.22.33.44:5555/pls/SAMPLE
1 Like

Now I see the single quotes are wrong, removing them makes this work.

The solution with variables also work. will use in the future when appropiate

Thank you guys :b::slight_smile: