LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 12-01-2009, 09:44 AM   #1
niknak
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="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!
 
Old 12-01-2009, 09:58 AM   #2
indiajoe
Member
 
Registered: Jan 2009
Location: India
Distribution: Porteus atma
Posts: 84

Rep: Reputation: 21
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

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

Original Poster
Rep: Reputation: 0
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
 
1 members found this post helpful.
  


Reply


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-16-2009 12:05 AM
Insert CRLF's with sed? unSpawn Programming 6 11-22-2006 08:46 AM
SED - replace / insert furquan Programming 5 03-01-2006 07:58 PM
insert a symbol with sed tonton Programming 5 08-31-2004 12:33 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 07:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:13 AM.

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