Obviously in a Unix environment using .*$
will match any number of characters till the end of the line.
However, when executing a sed
using
"ParameterValue": ".*$"
as my regex on a mac, I get the error
sed: 1: "s/"ParameterValue": ".* ...": unterminated substitute in regular expression
I expect it to match against "ParameterValue": "buildname"
where buildname could be any of three dozen different options in different formats, preventing a more exact regex.
The script will always be run from a mac environment so I have to have a solution that will work on a mac.
TL;DR: How do I match till the end of the line in bash on a mac?
EDIT: By request, my script. For security reasons I can only show this section. Image and grepname are both defined in earlier lines.
REPLACE='"ParameterValue":.*'
REPLACETO='"ParameterValue": "${IMAGE}"'
grep -A 1 -i "RTSMImageTag" ${GREPNAME}_parameters.json | xargs sed -i '' -E "s/$REPLACE/$REPLACETO"
And an excerpt from the relevant file;
"ParameterKey": "RTSMImageTag",
"ParameterValue": "buildname"
Essentially I need to replace this particular parameter value which is located in a newly generated file with one passed into the script. I was trying to avoid asking for someone to solve my problems for me by focusing on just the error, but if you have a better solution overall please let me know.