Skip to main content
3 of 4
more clarifications - translating whats in my head
knk
  • 133
  • 4

Extract text including parens

I have some text like this:

Sentence #1 (n tokens):
Blah Blah Blah
[...
 ...
 ...]
( #start first set here
 ... (other possible parens and text here)
 ) #end first set here

(...)
(...)

Sentence #2 (n tokens):

I want to extract the second set of parens (including everything in between) ,i.e.,

(
 ... (other possible parens here)
)

Is there a bash way to do this. I tried the simple

 's/(\(.*\))/\1/'
knk
  • 133
  • 4