-2

I want to do in place modification in README.md file, but also allow variable substitution. The line that I want to modify starts with "[![Data Layer]...".

I have tried:

sed -i "" "s|\[!\[Data Layer\].*|[![Data Layer](https://img.shields.io/badge/data%20layer-${number}%25-brightgreen)](file:///...)|g" README.md

With double quotes I'm getting error:

event not found: \[Data

I fixed it by changing to single quotes, but then it changes the line with ${number} as string and doesn't replace this variable by its value.

What should I do to make my variable substitution work?

nika
  • 1
  • 2
  • Please use single-quotes, and also just before and after `${number}`: `'s|\[!\[Data Layer\].....yer-'${number}';%25-brightgreen)](file:///...)|g'` – Luuk Aug 29 '23 at 07:17
  • To know what happens, study the output of: `echo '>>>'${USER}'<<<'` – Luuk Aug 29 '23 at 07:19

0 Answers0