regex – In arbitrary line of text, how can bash extract a named value after an equal sign?
This question (How to get values after an equal sign) is basically what I want:
Given a line of text, with named parameter looking syntax like color=red
, using bash how can you grab that color value (yielding red
)?
Except in that question, the line of text is entirely those key-value pairs, so the accepted answer utilizes bash’s eval
since that syntax happens fit very nicely.
I’m wondering for a generic line of text like ⎜ ↳ Synaptics TM3289-021 id=13 ]
how I could grab that id value (yielding 13
)?
Maybe utilizing regex, where I know the line will contain [whitespace]id=<TEXT I WANT>[whitespace]
?
Read more here: Source link