Split binary file with pattern

Hello!

Have some problem with extract files from saved session.

File contains any kind of special/printable characters.

DATA NumberA DATA
DATA Begin
DATA1.1
DATA1.2 NumberB1 DATA1.3
DATA1.4
End DATA
DATA
DATA Begin
DATA2.1
DATA2.2 NumberB2 DATA2.3
DATA2.4
End DATA
DATA
...
...
DATA Begin
 DATAXXX.1
 DATAXXX.2 NumberBXXX DATAXXX.3
 DATAXXX.4
 End DATA
 DATA

output file names are NumberANemberB1, NumberANemberB2 ... NumberANemberBXXX

contents

Begin
DATA1.1
DATA1.2 NumberB1 DATA1.3
DATA1.4
End

Begin
 DATA2.1
 DATA2.2 NumberB2 DATA2.3
 DATA2.4
 End
...
....
Begin
  DATAXXX.1
  DATAXXX.2 NumberBXXX DATAXXX.3
  DATAXXX.4
  End

Could you please help suggest me a way to do this.

Thank you very much!

Try this:

awk '/Begin$/{print $2; p=1; next}
/End/{print $1; p=0}
p' file

sorry, that i have posted not an exact question. there is no spaces in file. that's why i think awk isn't suitable...

So give the exact format of your input file and the desired output within code tags.

looks like this, but i could send real input and output files

input file

strings_of_useless_data
useless_data/krg01003265584.keyuseless_data
strings_of_useless_data
useless_dataBegin
strings_of_usefull_data
usefull_data/Name/im2/usefull_data
strings_of_usefull_data
End useless_data
strings_of_useless_data
useless_dataBegin
strings_of_usefull_data
usefull_data/Name/im10/usefull_data
strings_of_usefull_data
End useless_data

output files
im002_krg01003265584.key

Begin
strings_of_usefull_data
usefull_data/Name/im2/usefull_data
strings_of_usefull_data
End

im010_krg01003265584.key

Begin
 strings_of_usefull_data
 usefull_data/Name/im10/usefull_data
 strings_of_usefull_data
 End