0

Tried with following code:

revision=(revision="5.0")

sed -i "s/revision="1.0"/${revision}/g" /File-path/composite.xml)

But In the file the contents of revision="1.0" is replaced by ${revision}

1
  • The symptom you're describing is not consistent with your command; the symptom suggests that you used single quotes around the sed script. Commented Feb 24, 2016 at 6:03

2 Answers 2

1

Need to quote: "

sed -i "s/revision=\"1.0\"/${revision}/g" /File-path/composite.xml

Sign up to request clarification or add additional context in comments.

1 Comment

But In the file the contents of revision="1.0" is replaced by ${revision}, he made typo in his question.
0

Some syntax errors:

  • -i switch tell to execute infile replacement.
  • (...) tell to store an array of variables.
  • leading ) seem wrong.

My purpose:

revision='revision="5.0"'

sed -e "s/revision=\"[0-9.]*\"/${revision}/g" /File-path/composite.xml

or if you want file /File-path/composite.xml to be modified:

sed -e "s/revision=\"[0-9.]*\"/${revision}/g" -i /File-path/composite.xml

or even:

sed -e "s/revision=\"[0-9.]*\"/${revision}/g" -i.bak /File-path/composite.xml

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.