Reputation: 1
I am trying to replace ${dbPassword}
in a property file with a password including $
signs.
My command is the following, but I have no idea how to replace this properly.
run: @cat $(FILE_PATH) | sed -i .bak 's/$${dbPassword}/$(VARIABLE_WITH_PWD)/g' $(FILE_PATH)
Let's say my dbPassword is: 123$456$789
With this, I am getting the result: 123${dbPassword}456${dbPassword}789
Upvotes: 0
Views: 299
Reputation: 72657
Three problems:
$(FILE_PATH)
on stdin, and as a file argument to sed. Remove the cat pipe.So you might want to try this instead:
.PHONY: run
run:
sed -i .bak "s/$${dbPassword}/$(VARIABLE_WITH_PWD)/g" $(FILE_PATH)
This assumes you have an environment variable, dbPassword
and exported it prior to running make
. If that is not the case, please provide your complete makefile.
I also have removed the @
so you actually see what command make
is executing. There's no point in wearing a blindfold while debugging your makefile.
Upvotes: 1