I have in my package.json file this line :
"version": "5.0.0",
And I want to replace 5.0.0 with another dynamic value. I tried like this :
sed -i "s%5.0.0%5.1.1%g" "package.json"
But is not good, because I don't know previous value that is 5.0.0. Should I write a regex here?
5.0.0appears in a different line, which is not related to version? You need to describe in your regex the pattern which the line to be modified must fulfil. Note also that in your attempt, a string5X0Y0would also be replaced by5.1.1, because the period matches any single character.