trying to replace a string in sed with embedded { and $ and with -E or -r, the { is problematic for me.
according to the docs and many examples I have read, I should only have to escape the { and $ if testing for them. I have whittled it down the simplest case (below)
Probably something I do not understand
I can use my workaround, but this is something that should work with the \{ ?
Given string:
: "${TARGET_PART:=${MMC_PART2}}"
and part=5
I want to replace the ${MMC_PART2}} with ${MMC_PART5}}
The following does not work:
echo ': "${TARGET_PART:=${MMC_PART2}}"'| sed -r "s/:=\{(MMC_PART).}}/\1$part}}/g"
but the following does work - (replaced "{" with ".")
echo ': "${TARGET_PART:=${MMC_PART2}}"'| sed -r "s/:=.(MMC_PART).}}/\1$part}}/g"
What am I missing?
-ris the argument to enable EREs in old versions of GNUsedonly. Modern versions of GNU and BSDsedboth use-Eto enable EREs, just likegrepdoes.-Ehas also made it into the latest standard - pubs.opengroup.org/onlinepubs/9799919799/utilities/sed.html