Reputation: 335
I have a file called samconfig.toml
version = 0.1
~~~
parameter_overrides = "CognitoUserPoolName=\"aaa\" ApiAllowOrigin=\"'https://dev.xxxxxxxxx.amplifyapp.com'\" etc..
~~~
My sed command
sed -i '' -e "s#ApiAllowOrigin=\\\"'https.*com'\\\"#ApiAllowOrigin=\\\"'https://dev.yyyyyyyy.amplify.com'\\\"#g" ./samconfig.toml
It doesn't substitute the url. What's confusing about this, is that it contains all those single quotes, double quotes, back slashes..
I even checked with visualized regexp checker
Upvotes: 1
Views: 72
Reputation: 784958
You may use this sed
on macos:
sed -i.bak -E "s~(ApiAllowOrigin=\\\\\"'https://).*(\.com'\\\\\")~\1dev.yyyyyyyy.amplify\2~" file
cat file
version = 0.1
~~~
parameter_overrides = "CognitoUserPoolName=\"aaa\" ApiAllowOrigin=\"'https://dev.yyyyyyyy.amplify.com'\" etc..
~~~
Here:
\\\\
to match a single \
.-E
for extended regular expressionsUpvotes: 2