Need Help: Collecting similar messages in a file

Hi All,

Since i am very new to shell scripting, i need help from you guys.
Suppose there is a file containing:

Log message:
Ashish

"asasasa"
asasa
asasa
asasas.info1

Log message:
Kapil

"asasasa"
asasa
asasa
asasas..info1

Log message:
Ashish

"asasasa"
asasa
asasa
asasas..info2

Log message:
Kapil

"asasasa"
asasa
asasa
asasas..info2

Log message:
Ashish

"asasasa"
asasa
asasa
asasas..info3

Now i want to create different files containing info about same log messages,which means new files should be created like this:
ashish_log_message:
containing info1..info2..info3..

Kapil_log_message:
containing info1..info2..

Hoping to get reply soon.:slight_smile:

Try this:

     for each in `sed -n '/Log message:/{n;p;}' filename | sort | uniq`
        do
        sed -n '/'$each'/{n;p;n;p;n;p;n;p;n;p;}' filename >${each}_log_message
        done

With Awk:

awk '/^Log message:/{close(f);getline;f=$0"_log_message";next}{print>f}' filename 

Use nawk or /usr/xpg4/bin/awk on Solaris.