I am writing a shell script where in I need some help in matching and extracting pattern
ALARM_TYPE contain string 'Exception Type - timeOverThreshold Description - High CPU eHealth Alarm ID - 1000001'
I need to extract the string after Description -
and before Alarm ID
and store it in a new varaible ...speciafically in this example I am looking for High CPU eHealth
How can I do it simply does awk
, sed
works or any other simple thing.
Here's a literal translation of what you want to do using
GNU grep
:Or with
sed
:Test:
Results:
You can read more about lookahead and lookbehind assersions here. HTH.