Welcome!
Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

Help needed with sed

Here is where users who have been using MEPIS awhile and know the basics of linux and MEPIS can ask questions.
Post Reply
Message
Author
User avatar
anticapitalista
Forum Veteran
Forum Veteran
Posts: 5695
Joined: Sat Jul 15, 2006 10:40 am

Help needed with sed

#1 Post by anticapitalista » Fri Jul 03, 2015 2:56 pm

I have a index.html file like this. (snipped)

Code: Select all

<table id="menu-table" border="0">
<tr class="top"><td></td></tr>
  <tr class="chosen"><td><a href="index.html">Home</a></td><td>&#187;</td></tr>
  <tr><td><a href="icewm.html">IceWM</a></td><td> </td></tr>
  <tr><td><a href="fluxbox.html">Fluxbox</a></td><td> </td></tr>
  <tr><td><a href="jwm.html">jwm</a></td><td> </td></tr>
  <tr><td><a href="rox.html">Rox</a></td><td> </td></tr>
  <tr><td><a href="spacefm.html">SpaceFM</a></td><td> </td></tr>
  <tr><td><a href="conky.html">Conky</a></td><td> </td></tr>
  <tr><td><a href="smxi.html">Smxi</a></td><td> </td></tr>
  <tr><td><a href="persistence.html">Persistence</a></td><td> </td></tr>
  <tr><td><a href="remaster.html">Remaster</a></td><td> </td></tr>
  <tr><td><a href="snapshot.html">Snapshot</a></td><td> </td></tr>
  <tr><td><a href="streamlight.html">Streamlight</a></td><td> </td></tr>
  <tr><td><a href="connectshares.html">Connectshares</a></td><td> </td></tr>
  <tr><td><a href="droopy.html">Droopy</a></td><td> </td></tr>
  <tr><td><a href="wingrid.html">Wingrid</a></td><td> </td></tr>
<tr><td></td></tr>
When I add an app, I would like the deb to call sed to add its entry above <tr><td></td></tr>
When I install another app, I would like it also to get added above <tr><td></td></tr>

I also want the lines deleted when the app is purged.

app 1 to add/remove this string: <tr><td><a href="1-to-1_voice.html">1-to-1 Voice</a></td><td> </td></tr>
app 2 to add/remove this: <tr><td><a href="1-to-1_assistance.html">1-to-1 Assistance</a></td><td> </td></tr>

I know how to call sed in a .deb, but not how to add the string(s) above <tr><td></td></tr>

Thanks
anticapitalista
Reg. linux user #395339.

Philosophers have interpreted the world in many ways; the point is to change it.

antiX-17 "Heather Heyer" - lean and mean.
https://antixlinux.com

User avatar
BitJam
Forum Guide
Forum Guide
Posts: 2472
Joined: Sat Aug 22, 2009 11:36 pm

Re: Help needed with sed

#2 Post by BitJam » Fri Jul 03, 2015 3:22 pm

Sent a PM.
Will I cry when it's all over?
When I die will I see Heaven?

User avatar
Adrian
Forum Veteran
Forum Veteran
Posts: 8878
Joined: Wed Jul 12, 2006 1:42 am

Re: Help needed with sed

#3 Post by Adrian » Fri Jul 03, 2015 3:24 pm

I think something like this would work, not that you need to escape the slashes.

Code: Select all

sed -i '/<tr><td><\/td><\/tr>/i <tr><td><a href="1-to-1_voice.html">1-to-1 Voice<\/a><\/td><td> <\/td><\/tr>' filename

Post Reply

Return to “Regulars”