LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Newed a little help on using sed to insert html (https://www.linuxquestions.org/questions/linux-newbie-8/newed-a-little-help-on-using-sed-to-insert-html-772679/)

niknak 12-01-2009 08:44 AM

Newed a little help on using sed to insert html
 
Hi All

I am trying to run a simple sed one liner, but just cannot get it right no matter where i look.

I ned to insert a single line of html into index.php in place.

The line would be:

<a id="goog" href="#" onClick="window.open('test.php','iframe')">test this edit</a>

My one liner is:

sed -i '209 a\\<a id=\"goog\" href=\"#\" onClick=\"window.open(\'test.php\',\'iframe\')\"\>test this edit\<\/a\>' /var/www/html/index.php

I get: syntax error near inexpected token.

It looks to me like everything is escaped a OK, but i just cannot find the issue and its driving me mad.

Anyone able to point out what i expect is an obvious mistake I am just missing?

Thanks!

indiajoe 12-01-2009 08:58 AM

Hi
Try
Code:

sed -i "209a <a id=\"goog\" href=\"#\" onClick=\"window.est.php\',\'iframe\')\"\>test this edit\<\/a\>" /var/www/html/index.php
-Cheers
indiajoe

niknak 12-01-2009 09:21 AM

Thanks

That was almost there, but it pointed be perfectly in the correct direction, thank you so much.

For others, I needed a preceeding escape slash in the previous post to get it running:

sed -i "209a \<a id=\"goog\" href=\"#\" onClick=\"window.open(\'test.php\',\'iframe\')\"\>Tester\<\/a\>" /var/www/html/index.php

Again, many thanks


All times are GMT -5. The time now is 11:58 PM.