从shell脚本文件中提取版本号 [英] Extract version number from file in shell script

查看:3983
本文介绍了从shell脚本文件中提取版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写递增这是在给定的版本号的bash脚本

  {主要} {轻微} {}修改

例如

  1.2.13

有没有好的办法方便地提取使用这些东西的3个数字,像sed和awk这样我可以递增{}版本号和输出的完整版本号字符串。


解决方案

  $ V = 1.2.13
$回声$ {v%的。*} $(($ {V ## *} + 1))
1.2.14

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

{major}.{minor}.{revision}

For example.

1.2.13

Is there a good way to easily extract those 3 numbers using something like sed or awk such that I could increment the {revision} number and output the full version number string.

解决方案

$ v=1.2.13
$ echo "${v%.*}.$((${v##*.}+1))"
1.2.14

这篇关于从shell脚本文件中提取版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆