I'm having some trouble when attempting to remove a string between the string end and the character ;. At the moment it looks like I'm also picking up the string if on other lines as that string is also between end and ;. I've been attempting to omit the if string from the command but I don't seem to be having much look using the below sed command as I receive a error. The string triggername is what needs to be removed, but it's not consistently named that.
Example File Before:
end if; end triggername ;
Example File Expected:
end if; end;
The command I've been attempting to use is:
sed -i -e '/if/! s/\(end.*)\;/g' test
I was hoping the /if/! would omit all literal if strings from the next command but when I attempt to run it I receive the following error:
sed: -e expression #1, char 20: unterminated `s' command
Can anyone help me understand why I'm getting that error please? And if the sed command is mainly correct, if not what would you recommend to improve it.
Thank you! As suggested I've tried adding in an extra / at the end as I just require it removing not replaced. But now I have this error:
sed -i -e '/if/! s/\(end.*)\;//' test
sed: -e expression #1, char 20: Unmatched ( or \(
To me it looks like I have a closing bracket not too sure about the '\' . I have only done this a once before, so quite new.