使用Shell脚本从字符串中提取版本号

我需要从以下字符串中提取版本号。

模式看起来像这样。

通过使用Shell脚本

VAR1=1.1-g13ab57737123
Output 1.1

VAR1=1.2-g328891ahqq12
Output 1.2

VAR1=2.3-g123900a12328
Output 2.3


VAR2=abcd960_1.1-g13ab57737123
Output 1.1
dengfuji 回答:使用Shell脚本从字符串中提取版本号

这有效:

textView1 = findViewById(R.id.textView1);

或者如果您需要更长的电话号码:

$ VAR1=1.1-g13ab57737123
$ echo $VAR1
1.1-g13ab57737123
$ echo $VAR1 | grep -o "[0-9]\.[0-9]"
1.1
本文链接:https://www.f2er.com/3111953.html

大家都在问