I have a specs file:
Name: program Version: 2.3.3 Release: 0 ...
I want to update the version number every time it's built. I perform the build from a bash script so I'm calling
sed to update the SPECS file and a "version" file which holds the version number.
I am using the following sed script to perform the update:
sed -ri 's/^(Version:\s+)([0-9.]+)/\1$version/g' SPECS/*.spec
$version being provided by the bash script.
It's designed to look for the correct line and replace the version portion while preserving whatever whitespace has been used. I use
*.spec so that it will work with a spec file of any name.
I felt that a sed one-liner made the most sense given the requirement.