I have string this:
release/3.0.2.344
And I want to extract this:
release/3.0.2
pattern is like:
release/<number>.<number>.<number>.<number>
Use parameter expansion in bash:
$ v="release/3.0.2.344"
$ echo "${v%.*}"
release/3.0.2
% cuts off of the end of the variable, and the search pattern is a dot . followed by any characters *.
'.' followed by digits only, you can use ${v%.[[:digit:]]*}. What you have is fine in this case.