And now, after assembling the sed command string... well, I still figure sed's the right tool for the job, but that doesn't mean I'm not amused.
Ow, my head. But at least it works.
5:10 PM on Friday. So close....