Input data has group of records and I need to delete "orphan records" within this group.
Grouping is on position 1,10.
Position 12,3 is to identify record type.
If there is group where there is no record type "001" (only type "009") then I want them to be deleted and written to a new file.
In example below 2 records "0000001111" need to be deleted as they don't have type "001".
----+----1----+----2----+----3
0000000000 001
0000000000 009
0000000000 009
0000001111 009
0000001111 009
0000333333 001
0000333333 009
0000333333 009
0000333333 009
0000333333 009
So output files will look like this:
Original file:
----+----1----+----2----+----3
0000000000 001
0000000000 009
0000000000 009
0000333333 001
0000333333 009
0000333333 009
0000333333 009
0000333333 009
File with deleted records:
----+----1----+----2----+----3
0000001111 009
0000001111 009