Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 469  / 2 Years ago, wed, october 19, 2022, 7:00:27

When using this ubuntu command:



${HOME}/temp/.git describe --always --tags HEAD 


the output of this command is:



v0.1.5-2-p343h3d3


I want to extract 1.5 from the output above and check if it's greater than 1.5 or not.

Is there any solution for this.?


More From » 12.04

 Answers
3

You could do something like



${HOME}/temp/.git describe --always --tags HEAD  | awk ' {
match ($0, /[0-9]+.[0-9]+.[0-9]+/,m)
if(m[0]>"0.1.5"){
print("hello")
}
}'


This will check the first matching regex result. Just throwing another way to do this, although I'm not sure how much of a practical way this is for you.



Cheers


[#26320] Friday, October 21, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
whipstder

Total Points: 189
Total Questions: 110
Total Answers: 99

Location: Uzbekistan
Member since Sat, Feb 27, 2021
3 Years ago
;