Outputting formatted Result log file from old 30000 lines result log<help required>

Well I have a 3000 lines result log file that contains all the machine data when it does the testing... It has 3 different section that i am intrsted in

1) starting with "20071126 11:11:11 Machine Header 1"
1000 lines...

"End machine header 1"

2) starting with "20071126 12:12:12 Machine Header 2"
1000 lines...

"End machine header 2"

2) starting with "20071126 12:12:12 Machine Header 3"
1000 lines...

"End machine header 3"

With this their are a lot of junk data also..
I just want to grab these 3 headers and put in into different file With each header having his own sections
eg:
===================Header1 Start====================
<it's content>
===================Header1 End ====================
how I can do this .. I want something like this

./<New script> <old log file>

and it gives me a new log file.

Can you please help me in making this... I want to make it in bash scripting.

Hey guys.. Please show me some pointers.. Its kinda very urgent.

Rule 4 of the SIMPLE RULES OF THE UNIX FORUMS:

Do not 'bump up' questions

And now the obligatory question: is this a homework question? If so, we can't help you.
That's against rule 6:

Do not post classroom or homework problems.

Assuming that it's not, can you show us how far you've gotten so far?

Regards

Well Its not an Class Room as well as homework problem.. I am trying to make some real world test result documentation script.As i am new to shell domain.. I am not able to figure out this that easily, Till now I have done this much

#!/bin/sh
#set -x
file=$1
echo $file
while read line;
do 
echo $line 
done < $file

With this I am able to read my file properly but the data is not coming with proper indentation, It is loosing its initial spacing which I dont want.

If awk is allowed (anyhow it gives a direction to figure it out in bash):

#!/bin/sh

awk '
{
  if($0 ~ /^starting with .*Header /) {
    i++
    print "===Header"i " Start==="
    flag=1
    next
  }
  if($0 ~ /^"End Machine Header /) {
    print "===Header"i " End==="
    if(i==3) {
      exit
    }
    flag=0
  }
  if(flag) {
    print $0
  }
  next
}' $1

Regards

Hi,

This one:

awk '(NF==5 && $3=="Machine" && $4=="Header"){
flag=1
file=sprintf("%s.txt",$5)
}
(flag==1) {
print $0 >> file
close(file)
}
(NF==4 && $2=="machine" && $1=="End"){
flag=0
}' filename