From linux Bash can you help me on how to show only the
Monitoringmetric=1.5Count
instead of
Monitoringmetric=1.5Count;1;2
From linux Bash can you help me on how to show only the
Monitoringmetric=1.5Count
instead of
Monitoringmetric=1.5Count;1;2
FInally showed it but seems to be a long command, please advise if there is a way I can shorten this
$ echo "Monitoringmetric=1.5Count;1;2" | cut -f2 |sed -e 's/Monitoringmetric=//g' | cut -f1 -d ";" | sed -e 's/Count//g'
Since you seem to be interested only capturing the number after the Monitoringmetric=, you can do:
echo "Monitoringmetric=1.5Count;1;2" | sed -n -e 's/^Monitoringmetric=\([0-9.]*\).*/\1/p'
If your string is in a variable, you could also use ${a%%;*}, for example:
a="Monitoringmetric=1.5Count;1;2"
echo ${a%%;*}