A continuation of this question: parse first column of command output, get corresponding second column value
Say I have a command that outputs a string formatted as a table, as shown below.
What if the "pattern" I am looking for includes spaces? For example, if the table is:
First Characteristic: b
Second Characteristic: 89.4
Version: 58.93
Name of Device: myDevice
Name of Device Load: myDevice-load-123abc
What if I want to get the value next to "Name of Device Load" in the table above?
To clarify, I know the value I am looking for is next to "Name of Device Load." I do not know that it is in the 5th row of the output, and I do not know anything about what that value would look like (So I can't try pattern matching with something like "-load-", for example).
Best Answer
What about this :
This only keeps the line you are interested in, separates it into two fields (works only if
:
is only present once per line), then remove spaces.