Extract version number from file in shell script

后端 未结 8 1443
醉话见心
醉话见心 2020-12-24 13:04

I\'m trying to write a bash script that increments the version number which is given in

{major}.{minor}.{revision}

For example.

<         


        
8条回答
  •  臣服心动
    2020-12-24 13:14

    Pure Bash using an array:

    version='1.2.33'
    a=( ${version//./ } )                   # replace points, split into array
    ((a[2]++))                              # increment revision (or other part)
    version="${a[0]}.${a[1]}.${a[2]}"       # compose new version
    

提交回复
热议问题