I use curl and cut for output, as shown below.
var=$(curl https://avc.com/actuator/info | tr '"' '\n' | grep - | head -n1 | cut -d'-' -f -1, -3)
A varied var gets two types of values ββ(one at a time).
HIX_MAIN-7ae526629f6939f717165c526dad3b7f0819d85b HIX-R1-1-3b5126629f67892110165c524gbc5d5g1808c9b5
I'm actually trying to get everything to the last '-'. I am HIX-MAIN or HIX-R1-1 .
The command shown works just fine to get the HIX-R1-1 .
But I realized that this is the wrong way to do it when I have something like only 1 - in a variable; it gets me all the variable value (e.g. HIX_MAIN-7ae526629f6939f717165c526dad3b7f0819d85b ).
How do I get everything to the last '-' in var variable?
bash regex shell grep
Monica t
source share