I have a bash file and I want to store a version text in it (preferably "echo version 1.0.1
" so that it automatically prints out its own version when executed)
I am trying to make a command group that will update the version.
So far I've got
grep "echo version" ~/.bashrc | cut -c 14- | sed -e 's/\./\n/g'
which extracts "echo version 1.0.1", cuts out the "echo version " and splits the version between the dots
1
0
1
and I'm hitting my limit of regex, bash, and google-foo to extract the last number (patch version) which I could increment and write back to file.
Mainly, how do I get that last number?
Also if there's anything much better I should be doing, please do suggest.