I need to concatenate a variable number of lines between braces, the braces are nested so only braces that begin with a specific prefix pattern to the brace need to be concatenated:
header {
category1 (a) {
field1 : value1 ;
field2 : value2 ;
...
fieldn : valuen ;
}
new cat1 (b) {
newfield1 : newvalue1 ;
newfield2 : newvalue2 ;
....
newfieldn : newvaluen ;
}
...
}
The category and field names are variable, the trailing ";" may or may not have a preceding space. Any line may have spaces or tabs in front of it or between words/delimiters/etc.
The output should look like:
header {
category1 (a) { field1 : value1 ; field2 : value2 ; ... fieldn : valuen ; }
new cat1 (b) { newfield1 : newvalue1 ; newfield2 : newvalue2 ; .... newfieldn : newvaluen ; }
}
I'm using CentOS, so sed/awk/perl are available.
Thanks!