Multiple lines into a single line

Hi,

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 very between 1-4 lines.

Input
---
2010-02-22 12:25:32
191
---
2010-02-22 12:25:32
---

Output
--- , 2010-02-22 12:25:32 , 191
--- , 2010-02-22 12:25:32

Thanks In advance

What have you tried?

Try:

awk '{ORS="\n";} NF==2 || /^-/ { ORS=","; }1' < file
awk 'END{print _}/^-/{if(_)print _;_=$0;next}{_=_" , "$0}' infile
1 Like

Thanks danmero, your command work perfectly.
:b: