[Discuss] Please help with a sed script

Dan Ritter dsr at randomstring.org
Tue May 25 08:46:10 EDT 2021


Bill Horne wrote: 
> Thanks for reading this: I appreciate your time.
> 
> I'm the Moderator of The Telecom Digest, which is the oldest e-zine on the
> Internet.
> 
> The readers send in pointers to articles of interest, and each day, other
> readers whom subscribe with the "digest" option receive an email with all
> the previous day's stories.
> 
> Here's the table-of-contents from a typical day:
> 
>    * 1 - [telecom] Can robocalls be tracked? - "bob prohaska"
>    <bp at remove-this.www.zefox.net>
>    * 2 - Re: [telecom] Can robocalls be tracked? - Bill Horne
>       <malQRMassimilation at gmail.com>
>    * 3 - [telecom] Verizon Media debuts ad-targeting solution without
>    identifiers
>       - Moderator <telecomdigestsubmissions at remove-this.telecom-digest.org>
> 
> And here's what I'd like to change it to, using (if possible) sed:
> 
>        (tr)(td)Can robocalls be tracked?(/td)(/tr)
>        (tr)(td)Re: Can robocalls be tracked?(/td)(/tr)
>        (tr)(td)Verizon Media debuts ad-targeting solution without
>        identifiers(/td)(/tr)
> 
>        ("less-than" and "greater-than" symbols have been changed to
>        parens here for obvious reasons.)
> 
> Things to note:
> 
> 1. The Subjects lines vary in length, and may contain hyphens.
> 2. The name and email of the contributor is also published with the
>    actual post, further on in each digest, so it doesn't have to appear
>    in the Table of Contents.
> 3. The "m" option of sed, which the manual says will do a multi-line
>    "s" command, doesn't appear to work on the OS I'm using, which is
>    Ubuntu 16 LTS.
> 
> Up until now, I've been doing this change every day, with emacs macros and
> the rest by-hand. I want to automate a lot more of the daily work, so I'm
> hoping that there's a way to get Linux sed to do that. I don't need sed per
> se: if awk or some other utility would be a better choice, please tell me
> about that possible solution instead.

It might be easier to get your digest software to emit this.
What are you using?

Also, why single-line tables rather than ul and li ? Then you
could just insert (ul) at the beginning, turn the first \*
encountered into a (li), and then pop a (/ul) at the end.

-dsr-


More information about the Discuss mailing list