stringbashawksed

bash for parsing all strings between triple curly brackets


I have the following text:

{{{VSER}}} is doing well. He went to {{{MARKET}}}.
It is very useful {{{RESOURCE}}}

I would like to parse string between {{{ and }}} run a script echo $TEXT | somescript, then the result should be:

VSER
MARKET
RESOURCE

Trying with sed:

echo $TEXT | sed 's/.*{{{ //' | sed # /}}}.*$//'

However, it returns {{{VSER , even VSER is not returned.


Solution

  • echo $TEXT | awk -vRS="}}}" -vFS="{{{" '{print $2}'