Extract version number from file in shell script

后端 未结 8 1408
醉话见心
醉话见心 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:28

    Yet another shell way (showing there's always more than one way to bugger around with this stuff...):

    $ echo 1.2.3 | ( IFS=".$IFS" ; read a b c && echo $a.$b.$((c + 1)) )
    1.2.4
    

    So, we can do:

    $ x=1.2.3
    $ y=`echo $x | ( IFS=".$IFS" ; read a b c && echo $a.$b.$((c + 1)) )`
    $ echo $y
    1.2.4
    

提交回复
热议问题