I've some files with the following data and i need to convert the lines between the separator ---, into a single line. I've tried with the paste cmd but my main problem is that the number of lines between the separator is not fix, it can vary between 1-4 lines.
My problem is that this solution only works on Ubuntu 9.10 and i recently upgraded my machine to Ubuntu 10.04, and when i execute the awk command it only returns the last line before the separator (---).
awk '
function p()
{
if( buffer )
print "---" buffer; # print if it existed; dont print for last seperator
}
/^---/ {
p(); # print if not first
buffer = ""; # reset
next;
}
{ buffer = buffer ", " $0; } # add lines to buffer
END { p(); } # handle case of no terminating separator
' <input-file