While I agree with the advice above, that you'll want to get a parser for anything more than tiny or completely ad-hoc, it is (barely ;-) possible to match multi-line blocks between curly braces with sed.
Here's a debugging version of the sed code
sed -n '/[{]/,/[}]/{
p
/[}]/a\
end of block matching brace
}' *.txt
Some notes,
- -n means 'no default print lines as processed'.
- 'p' means now print the line.
- The construct
/[{]/,/[}]/
is a range expression. It means scan until you find something that matches the first pattern (/[{]/)
AND then scan until you find the 2nd pattern (/[}]/)
THEN perform whatever actions you find in between the { } in the sed code. In this case 'p' and the debugging code. (not explained here, use it, mod it or take it out as works best for you).
You can remove the /[}]/a\ end of block debugging when you prove to your satisfaction that the code is really matching blocks delimited by {,}.
This code sample will skip over anything not inside a curly brace pair.
It will, as noted by others above, be easly confused if you have any extra {,} embedded in strings, reg-exps, etc., OR where the closing brace is the same line, (with thanks to fred.bear)
I hope this helps.