How can I use sed to replace text and also append to end of line for the match in question?
I have a sed file which is doing many substitutions.
One of them changes ~= to match( using /=\~/ s/=\~/match( /
When doing this, I also want to add a ")" (space + end paren) at the end of the line in question (that met the original match)
I tried this with this sed line:
/=\~/ s/=\~/match(/ s/$/ )/
but I got our favorite sed: -e expression #1, char 77: unknown option tos'`
(line 77 'cos this sed has lots of other stuff (omitted)).
How can I append a ) for these lines? Can I do it within this match or do I need another line for it? I would like it to only be for these matches or I might end up adding an extra ) for "existing" match() expressions.
fwiw the full sed is..
sed -i 's/\.should/)\.to/
/\.to ==/s/==/eq/
/=\~/ s/=\~/match(/ s/$/ )/ <--- line in question
/[^}.to|end.to]\.to[[:space:]]/ s/\(\S\)/expect(\1/
/[^}.to|end.to]\.to_not[[:space:]]/ s/\(\S\)/expect(\1/
s/[^}.to|end.to].to[[:space:]]/).to /
s/to_receive/to receive/
s/to_not_receive/to_not receive/' ../_spec_seded/"$file"
flexmight be able to help.