Reading multiple lines with condition

Hi guys,

I need to read following lines and put them in same row �.

text: Abcd5437_XYA0_B1_WXYZ_BE
               99:00:14:42:55:01:d4:22
               99:00:14:42:70:01:d4:22
               99:00:14:42:55:03:a0:22
               99:00:14:42:70:03:a0:22
               99:06:01:55:30:55:2d:67
               99:06:01:77:30:55:2d:67
text: ABC1234_E1_A1_BE00_Abcd6520_XYA0_B1     
               99:06:01:77:39:a0:17:4b
              99:06:01:55:39:a0:17:4b
               99:00:14:42:55:01:d4:22
text: ABC1234_E1_B1_BE00_Abcd6520_XYA0_B1     
               99:00:14:42:70:01:d4:22
               99:06:01:77:39:a0:17:4b
text: ABC1234_E2_A1_BE00_Abcd6520_XYA0_B1     
               99:06:01:77:39:a0:17:4b
               99:00:14:42:55:03:a0:22
               99:06:01:55:39:a0:17:4b

I am using getline function but it is not working the way I want �.I want to see this as below

text: Abcd5437_XYA0_B1_WXYZ_BE,99:00:14:42:55:01:d4:22,99:00:14:42:70:01:d4:22,99:00:14:42:55:03:a0:22,99:00:14:42:70:03:a0:22,99:06:01:55:30:55:2d:67,99:06:01:77:30:55:2d:67
text: ABC1234_E1_A1_BE00_Abcd6520_XYA0_B1,99:06:01:77:39:a0:17:4b,99:06:01:55:39:a0:17:4b,99:00:14:42:55:01:d4:22
text: ABC1234_E1_B1_BE00_Abcd6520_XYA0_B1,99:00:14:42:70:01:d4:22,99:06:01:77:39:a0:17:4b
text: ABC1234_E2_A1_BE00_Abcd6520_XYA0_B1,99:06:01:77:39:a0:17:4b,99:00:14:42:55:03:a0:22,99:06:01:55:39:a0:17:4b

Any help will be appreciated.

Thank you ....

This should do the trick:

 awk '
BEGIN{s="";}
{
        if($0 ~ "text")
        {
                if(length(s))
                {
                        print s;
                        s = "";
                }
        }
        s=s$0;
}
END{print s}
' your_input_file
 
awk 'function p(){if(length(s))print s}/^text:/{p();s=$0;next}{s = s "," $0}END{p()}' file

OR like this

awk '/^text:/{printf("%s%s",(++i == 1 ? "": RS), $0); next}{printf("%s%s", OFS,$0)}END{print ""}' OFS=',' file

perfect ...... Thank you.....

how do I put a space between first line and 2nd?

I'm lost. Where do you want the space? Your sample output showed that you wanted commas separating input lines in each group and didn't show double spaced lines in the output. The only spaces that appeared in your sample output was the space between text: . Do you want all of the spaces that were hidden by not using CODE tags at the start of each line other than the 1st line in each group to appear after the commas?

Please show us what output you really want (and use CODE tags this time).