xcodeshellshjenkins-scriptler

How to replace a value in shell script


I am beginner in shell script, I have a string like ${VERSION_NUMBER}${VERSION_SUFFIX} here i would like to replace ${VERSION_NUMBER} with my own value like 1200 kind of. can you suggest me ?


Solution

  • You can do:

    s='${VERSION_NUMBER}${VERSION_SUFFIX}'
    sed 's/\${VERSION_NUMBER}/1200/' <<< "$s"
    1200${VERSION_SUFFIX}