Input example:
START{
some text
{
more text}
almost there
}
nothing important{
...
Desired output:
START{
some text
{
more text}
almost there
}
First open bracket could be in different positions:
START{...
START {...
START
{...
Start could also contain special characters such as: *
I want to print out everything including from START and everything between first matching {} (in bash). I was thinking about having a counter that increments when it finds { and decrements when it finds }. When the result is zero it stops printing out (curly brackets are always matching).
some text,more text,almost there, ornothing importantinclude any ofSTART,{, or}? For example if this were a programming lanaguage you were trying to parse then there might be strings (e.g."{"or"where is START?") or comments (# {or// {or// not really START) including any of those but which you would not want to consider when counting.START, curly brackets can be nested, but they're always in pairs. Of course there could be more text or more brackets.STARTcan really beSTA*RTor similar with regexp metachars or typical delimiters then show that as your sample input/output rather than just the sunny-day alphabetic chars case.