definitely interested.

Grumble Grumble Grumble sed Grumble Grumble

In various on September 4, 2008 at 6:12 pm

What if I had a shitton of ancient shtml files that all, somewhere near the top of the body, contained a line like “BEGIN MAIN CONTENT”?

What if I wanted to wipe everything above that and substitute some include script? I’d use sed, right?

If I figure this out before you do, I’ll post my command line here.

This variant …

sed -i -e '/<html>/,/<title/s/[.^M\n]*/pfeh/' testy.shtml

From the line that contains <html> to the line that contains <title, do something. Something, in this case is adding the word “pfeh” to the start of each line. Not quite it.

I think the secret lies in using /i and /a to insert or append lines.

I don't have a comment policy, for better or for worse. If I really feel insulted by a comment I might take it down, but I'll always tell you why. I always flag cyrillic comments as spam even though I can't read them so technically I have no idea what they're about. I apologize for that business about comments being a "privilege" -- my penance for using a template out of the box. Rest assured that it is my privilege to have you here!