Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-01-2009, 08:44 AM   #1
LQ Newbie
Registered: Apr 2009
Posts: 7

Rep: Reputation: 0
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="'test.php','iframe')">test this edit</a>

My one liner is:

sed -i '209 a\\<a id=\"goog\" href=\"#\" onClick=\"\'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?

Old 12-01-2009, 08:58 AM   #2
Registered: Jan 2009
Location: India
Distribution: Porteus atma
Posts: 84

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

Last edited by indiajoe; 12-01-2009 at 08:59 AM.
1 members found this post helpful.
Old 12-01-2009, 09:21 AM   #3
LQ Newbie
Registered: Apr 2009
Posts: 7

Original Poster
Rep: Reputation: 0

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=\"\'test.php\',\'iframe\')\"\>Tester\<\/a\>" /var/www/html/index.php

Again, many thanks
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert using sed ZAMO Linux - General 6 01-15-2009 11:05 PM
Insert CRLF's with sed? unSpawn Programming 6 11-22-2006 07:46 AM
SED - replace / insert furquan Programming 5 03-01-2006 06:58 PM
insert a symbol with sed tonton Programming 5 08-31-2004 11:33 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration