Ask Your Question
3

What is the Linux bash or sed command that can be used to increase a version number?

asked 2023-06-03 06:23:09 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-06-03 06:51:01 +0000

woof gravatar image

One option is to use the sed command to search for the version number pattern and replace it with an incremented value. For example, if the version number is in the format "x.y.z", the command could be:

sed -i 's/\(.*\)\.\(.*\)\.\(.*\)/\1.$((\2+1)).\3/' version.txt

This command will find the version number in the file "version.txt" and increment the middle number. Alternatively, if you just want to increment the last number, you can use:

sed -i 's/\(.*\)\.\(.*\)\.\([^\.]*\)$/\1.\2.$((\3+1))/' version.txt

This command will increment the last number in the version string.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-03 06:23:09 +0000

Seen: 1 times

Last updated: Jun 03 '23