Smith Dwayne
Smith Dwayne

Reputation: 2807

Sed command in makefile

I get a Input String from @read command in makefile.

@read -p "Enter Web Url:" weburl; \

I want to use the weburl variable in my below sed command in makefile.

@read -p "Enter Web Url:" weburl; \
sed 's/^\(ServerName:\)$/\1 $$weburl/' $(LOCALCONFIGDIR)/myfile.conf

But It is not executing the sed command after reading the input.

Upvotes: 0

Views: 2143

Answers (1)

oliv
oliv

Reputation: 13249

Be careful with $ sign in Makefile, especially when used in a shell statement. You can replace your sed command with this:

sed 's/^\(ServerName:\)$$/\1 '$$weburl'/' $(LOCALCONFIGDIR)/myfile.conf

Note the end of the line is $$. Note also that variable substitution can't be done with single quote ', that's why the variable is outside of it.

With some sed optimisation, I'd rather advise you this:

sed "/^ServerName:/s/$$/ $$weburl/" $(LOCALCONFIGDIR)/myfile.conf

Upvotes: 2

Related Questions