0

I am trying to replace a string within a couple of similar sql scripts. in my toolbox I have a for loop as well as grep and sed inside a bash script.

#!/usr/bin/env bash

for efa_instance in efa_bauen_bb efa_bauen_bw do echo ${efa_instance} secret=$(grep ${efa_instance}_user efa_secret.csv | cut -d; -f3) echo ${secret} echo replacing password for ${efa_instance} sed -i 's/<via Mail>/${secret}/' ${efa_instance}.service.sql done

this, however replaces the string <via Mail> with literally the string ${secret} instead of the value stored in the ${secret} variable.

the components of this work as expected, just trying to use sed to actually replace the placeholder fails.

Am i ot seing something obvious or is my approach flawed by design.

maybe worth mentioning (just if somebody was tempted to recommend that) ... I have never used awk and have no knowledge ot if whatsoever

vrms
  • 139

1 Answers1

2

Use " instead of ':

sed -i "s/<via Mail>/${secret}/" ${efa_instance}.service.sql
jonasmike
  • 169