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
FSHL (const TP Buffer)
{
INT32
FSHL_lm (const TP Buffer)
{ WORD32 ugo = 0; ...
What I am trying to do is scan for independant open braces {and append it to the previous non-blank line .The match should not occur for an open brace appended by anything in the same line .
The expected output :
INT32
FSHL (const TP Buffer){
INT32
FSHL_lm (const TP Buffer)
{ WORD32 ugo = 0; ...
Thanks for the replies .
This might work for you (GNU sed):
Explanation:
$!Nunless 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.Pprint upto and including the first newline.Ddelete upto and including the first newline (if so do not start a new cycle).