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
One way using awk
:
awk '!(NF == 1 && $1 == "{") { if (line) print line; line = $0; next; } { sub(/^[ \t]+/, "", $0); line = line $0; } END { print line }' file.txt
Or broken out on multiple lines:
!(NF == 1 && $1 == "{") {
if (line) print line
line = $0
next
}
{
sub(/^[ \t]+/, "", $0)
line = line $0
}
END {
print line
}
Results:
INT32
FSHL (const TP Buffer){
INT32
FSHL_lm (const TP Buffer)
{ WORD32 ugo = 0; ...
HTH