Extract version number from file in shell script

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

    Awk makes it quite simple:

    echo "1.2.14" | awk -F \. {'print $1,$2, $3'} will print out 1 2 14.

    flag -F specifies separator.

    If you wish to save one of the values:

    firstVariable=$(echo "1.2.14" | awk -F \. {'print $1'})

提交回复
热议问题