not able escape single quotes (') while using sed command

Viewed 40

while using,

sed -i '122 i <button type="button" onclick="window.open('https://localhost:$ctrl','_blank')">CTRL01</button>' SCP_PortForwarding.html;

in SCP_PortForwarding.html i am getting,

<button type="button" onclick="window.open(https://localhost:10941,_blank)">CTRL01</button>

but want to print,

<button type="button" onclick="window.open('https://localhost:10941','_blank')">CTRL01</button>

where $ctrl is randomly assigned port number.

1 Answers

You can try this sed

$ sed -i "122 i <button type=\"button\" onclick=\"window.open('https://localhost:$ctrl','_blank')\">CTRL01</button>" SCP_PortForwarding.html
Related