can I use sed
or awk
to append to the previous line if a match is found ?
I have a file which has the format :
INT32
This might work for you (GNU sed):
sed '$!N;s/\n\s*{\s*$/{/;P;D' file
Explanation:
$!N
unless the last line append the next line to the pattern space.s/\n\s*{\s*$/{/
replace a linefeed followed by no or any amount of white space followed by an opening curly brace followed by no or any amount of white space to the end of the string, by an opening curly brace.P
print upto and including the first newline.D
delete upto and including the first newline (if so do not start a new cycle).