split string

I am trying to get some data from a file and print it on the same line.
I have a script that gets the body of emails and display it, but i want it to display each emails body in one line no matter how big it is. eg

insted of this

email1: bla bla bla
bla bla bla
bal
email2: bla bla bla bal
bla bla bal

i want it to print

email1: bla bla bal bal bal bal
email2: bla bal bla blalba bla bla

the code i used to print the body is

awk '/Content-Type/{p=1;c++;print "Email-",c;}/Date/{p=0}p' file

Thank You!

what is your full input ?

Just changing your awk program a bit:

awk '/Content-Type/{p=1;c++;printf("\n%s%s ","Email-",c);}/Date/{p=0}p{printf("%s ",$0)} END{print}' file

Do you mean the actual body?

---------- Post updated at 09:00 PM ---------- Previous update was at 08:51 PM ----------

It is not printing the emails one after another line by line? it is still breaking the long emails.

thanks

Sigh....:wall: why didn't I ask for the input before?

Please provide the input..

X-Gm-Message-State: ALoCoQlKshFP6tmOEy2s1QR3S1Jz+MxBV14nq785bMuizQkLNlHBS5IO/6HVa+UBngxbf8sUkiU7

Hello chatura,

Applications Open Submit your Social Enterprise Project Idea - SEEDS Investment Fund; Free Social Enterprise Event at Federation Square 11 July

Are you working on a student driven project or outside of the classroom on a social or environmental idea?

Have you considered pitching your idea for funding to take your project enterprise idea to the next level?
the university SEEDS have just opened their 2012 Investment Fund and are inviting applications for projects that are led by students.

like this ?

# cat file
Date:
From:
Subject:
To:
Content-Type:
---body --1-2-
-----3----
-----4----
-----5----
Date:
From:
Subject:
To:
Content-Type:
----body --6 7---
----8---
----9---
Date:
From:
# awk '/Content-Type/{while(getline){if($0~/Date/)break;x=x?x" "$0:$0}print "email",++i,": " x;x=""}' file
email 1 : ---body --1-2- -----3---- -----4---- -----5----
email 2 : ----body --6 7--- ----8--- ----9---

thank you

---------- Post updated at 10:06 PM ---------- Previous update was at 10:02 PM ----------

thank you very much!