What is the optimal way to extract values between braces in bash/awk?

Viewed 10314

I have the output in this format:

Infosome - infotwo: (29333) - data-info-ids: (33389, 94934)

I want to extract the last two numbers in the last pair of braces. Some times there is only a single number in the last pair of braces.

This is the code I used.

echo "Infosome - infotwo: (29333) - data-info-ids: (33389, 94934)" | \
  tr "," " " | tr "(" " " | tr ")" " " | awk -F: '{print $4}'

Is a more clean way to extract the values? or a more optimal way?

3 Answers
Related