> But now I get complaints about an error in sed ("unescaped newline
> inside substitute pattern").
I remember problems with sed back when I was using nix with FreeBSD.
Can you tell it to use GNU sed? To make it work with BSD's sed, you
could try putting a \ before the newline in the argument to sed.
James