Avoid bash, sed, awk et al. and use https://github.com/mikefarah/yq instead.
bash
sed
awk
See https://unix.stackexchange.com/questions/646851/struggling-using-sed-command-with-variables.