I'm guessing this has to be an escaping issue, but I can't find it. What's most frustrating is that this is based on an old sed script I used that worked, so why can't I make it work when I try to re-use it a year later? ;)
Framework:
I have a file with a list of filenames in it that all need the same string of HTML searched and replaced.
I need to replace
<a href="foo.html">Foo</a>
with
<a href="foo.html">Foo</a><a href="bar.html">Bar</a>
I was using:
#!/bin/bash
for i in $(cat sourcelist); do cat $i | sed 's,<a href="foo.html">Foo</a>,<a href="foo.html">Foo</a><a href="bar.html">Bar</a>,g' > $i.bak ; mv $i.bak $i ; done
#end
But I'm getting the sed error "unterminated `s' command".
I've tried escaping the double quotes, the slashes, both, and still can't get it to parse.
It's late, and I'm losing focus. Any sharp eyes out there that can catch what I'm missing?