How to copy records from an input file until some condition is met? Here I want to copy records till "ERROR - PROCESS CLOSED" is occured.
Input Data:
ERROR - PROCESS CLOSED
RET0 13 001 XXX48 001 N
RET2 13 001 XXY48 002 T
RET9 13 001 XXZ48 001 T
RET8 13 001 XBX48 002 N
RET9 13 001 XYT48 003 N
ERROR - PROCESS CLOSED
RET1 83 001 XXX48 001 N
RET5 83 001 XXY48 002 T
RET7 83 001 XXZ48 001 T
ERROR - PROCESS CLOSED
RET2 10 001 XXX48 001 N
RET6 10 001 XXY48 002 T
RET1 10 001 XBX48 002 N
RET2 10 001 XYT48 003 N
RET0 13 001 XXX48 001 N
RET2 13 001 XXY48 002 T
RET9 13 001 XXZ48 001 T
RET8 13 001 XBX48 002 N
RET9 13 001 XYT48 003 N
ERROR - PROCESS CLOSED
RET1 83 001 XXX48 001 N
RET5 83 001 XXY48 002 T
RET7 83 001 XXZ48 001 T
ERROR - PROCESS CLOSED
RET2 10 001 XXX48 001 N
RET6 10 001 XXY48 002 T
RET1 10 001 XBX48 002 N
RET2 10 001 XYT48 003 N
I want to create three files out of it.
File-1:
ERROR - PROCESS CLOSED
RET0 13 001 XXX48 001 N
RET2 13 001 XXY48 002 T
RET9 13 001 XXZ48 001 T
RET8 13 001 XBX48 002 N
RET9 13 001 XYT48 003 N
RET0 13 001 XXX48 001 N
RET2 13 001 XXY48 002 T
RET9 13 001 XXZ48 001 T
RET8 13 001 XBX48 002 N
RET9 13 001 XYT48 003 N
File-2:
ERROR - PROCESS CLOSED
RET1 83 001 XXX48 001 N
RET5 83 001 XXY48 002 T
RET7 83 001 XXZ48 001 T
RET1 83 001 XXX48 001 N
RET5 83 001 XXY48 002 T
RET7 83 001 XXZ48 001 T
File-3:
ERROR - PROCESS CLOSED
RET2 10 001 XXX48 001 N
RET6 10 001 XXY48 002 T
RET1 10 001 XBX48 002 N
RET2 10 001 XYT48 003 N
RET2 10 001 XXX48 001 N
RET6 10 001 XXY48 002 T
RET1 10 001 XBX48 002 N
RET2 10 001 XYT48 003 N
Please help.
Thanks.