Fetch lines between 1st and 4th similar pattern

Hi Folks,

I have a big file that looks like below

==========
kjhjl
kjlklkkhcgflj
fgf
==========
xsww23edc
ccdde3rfv
ceerfcc
vff4
==========
zaq12wsx
xsw23edc
==========

==========
zxcvb
asdfg
qwert
==========
1qaz2wsx
2wsx3edc
==========
4rfv5tgb
6yn7ujm
==========

Now I need to fetch the lines between the first "==" to fourth "==" in a loop and put only this contents between the 1st and 4th "==" in the separate file. Now I should have 2 files as seen below

File 1 :

==========
kjhjl
kjlklkkhcgflj
fgf
==========
xsww23edc
ccdde3rfv
ceerfcc
vff4
==========
zaq12wsx
xsw23edc
==========
File 2:

==========
zxcvb
asdfg
qwert
==========
1qaz2wsx
2wsx3edc
==========
4rfv5tgb
6yn7ujm
==========

Please help me with this

Hello jayadanabalan,

Could you please try following and let me know if you have any queries.

awk -v B=1 '/^==/{A++}  {print > "File "B} A==4{B++;A=""}'   Input_file

Thanks,
R. Singh

works like a charm !!!!

I got another issue actually.

Say my bulk file is like seen below

==============
= Fruit      : lkjlkjkl
= Veggie   : rdhghjk
==============
zaq12wsx
xsw23edc
cde34rfv
==============
= Done     :  May 05
= Time     :  07:00 AM
==============

==============
= Fruit      : gfdgfhf
= Veggie   : mjgwecj
==============
zaq12wsx
xsw23edc
cde34rfv

==============
= Fruit      : fgkjkl
= Veggie   : xfdxgfc
==============
zaq12wsx
xsw23edc
cde34rfv
==============
= Done     : May 01
= Time     : 05:00 PM
==============

If you see the second lot, there is no Done and the log is incomplete. So the 3rd and 4th "==" is missing here.

How do I separate this alone ?

And, note that unless you provide more details such that the start of a transaction can be reliably identified, there might not be any way to guess at what you really want to happen. Although the second line of each transaction in your second sample input file, you have not stated that that will be true in all correctly formatted transactions. Trying to guess at requirements from a two and a half transaction sample is dangerous.