I have the following text
abc <THIS> abc <THAT> abc <WHAT> abc
where abc is a placeholder for a well defined expression. I’d like to extract the 3 terms in the brackets and save them in 3 separate variables. Is is possible to do that without parsing the text 3 times? Basically I’d like to capture and somehow “export” multiple groups.
It’s clear that I can extract one of them like this:
VARIABLE=`echo $TEXT | sed "s_abc <\(.*\)> abc <.*> abc <.*> abc_\1_g"`
But is it possible to get all 3 of them without running sed 3 times?
Other (portable) solutions without sed are also welcome.
If there are any characters that you know will not appear in
THIS,THAT, orWHAT, then you can write something like this:telling
sedto use that separator in its output, andreadto use that separator in its input.