How do I get the version number from a file and increase the version with 1? I would like to store the version to a variable, increase it with one en save the new version in the file.
Let's say I have a simple config file (application.config) like this:
[section1]
Some = variables
[Version]
version = 1.0
The version always starts with "version = " (without the quotes, I added them to demonstrate the space after =). I would like to:
- Change 1.0 to 1.1 (1.9 should get 1.10, 1.99 should get 1.100 etc).
- Store 1.1 to a variable to use it in another part of my script.
I tried it with sed:
sed -i -r 's/version = [0-9]+.[0-9]+/version = $Version/I' application.config
This works if I manually enter $version, hoe do I get it from the file itself?