sean finney on 3 Dec 2009 16:36:23 -0800

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] sed newbie question

On Thu, Dec 03, 2009 at 06:46:08PM -0500, Douglas Muth wrote:
> On Thu, Dec 3, 2009 at 6:30 PM, Michael Lazin <> wrote:
> > Hi, I am interested in writing a shell script that will remove malicious
> > iframes from peoples websites.  I am a scripting newbie and a sed newbie.  I
> > decided to start by playing around with it.
> >
> > sed '/iframe/d' test.html
> >
> > cat test.html
> > <iframe>frame src=</iframe>
> >
> > Why didn't this sed line delete the iframe line from my test file?
> No idea, but I can tell you how I would do it:
> cat test.html | sed -e s/iframe//g

      (i was needlessly used)   
  \  o

	says the unix cat

and note that what you propose would also delete any mention of an iframe
in a paragraph, such as the mailing list archive where these messages go :)

if you're trying to do anything reasonably complex, i suggest you look into
using a scripting language with support for dom manipulation.  in particular
python + beautiful soup is great.  you could do something like say "find
all iframes and replace them with an empty div" in probably half a dozen
lines of code.


Attachment: signature.asc
Description: Digital signature

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --