user256717
user256717

Reputation:

sed replacing literal ${something} within xml tags

I am trying do the following:

find . -iname pom.xml 
| xargs sed -i 
 "s/<version>${project.version}</version>/<version>0.9.1-SNAPSHOT</version>/g"

But it doesn't work. What all I need to escape here?

I tried multiple combinations like escaping / in version and $.

Upvotes: 1

Views: 768

Answers (2)

Ben Hocking
Ben Hocking

Reputation: 8072

The match string you want is <version>\${project\.version}<\/version> (escape the $, the ., and the /). The replace string you want is <version>0.9.1-SNAPSHOT<\/version> (escape the /).

Combined that yields:

"s/<version>\${project\.version}<\/version>/<version>0.9.1-SNAPSHOT<\/version>/g"

Upvotes: 0

Prince John Wesley
Prince John Wesley

Reputation: 63698

Escape $ and .. Use different delimiter(;).

sed "s;<version>\${project\.version}</version>;<version>0.9.1-SNAPSHOT</version>;g"

Upvotes: 5

Related Questions