I have an html file and I want using bash, to insert a dollar sign before the curly brackets, so something like:
<h1>My name is {HOSTNAME}. <h1>
becomes:
<h1>My name is ${HOSTNAME}. <h1>
My code so far:
while read -r line; do
new_index=$(echo ${line} | sed '/^{/s/^/\$/') #the line to insert the $
echo $new_index
done < "web/index.html" #the file I'm reading from
But it doesn't seem to work, why?
Edit: I'm using bash for exercising purposes only, not a real life application.