I have file which I want to extract and rearrange certain data , Old file contains a raw data this file is Input
reference:cve,2017-8962 sid:45885 reference:cve,2016-10033 reference:cve,2016-10034 reference:cve,2016-10045 reference:cve,2016-10074 sid:45917 reference:cve,2017-8046 sid:45976 reference:cve,2018-6577 reference:cve,2018-6578 sid:46062
and the below file is the New file contains the required output
reference:cve,2017-8962 sid:45885 reference:cve,2016-10033 sid:45917 reference:cve,2016-10034 sid:45917 reference:cve,2016-10045 sid:45917 reference:cve,2016-10074 sid:45917 reference:cve,2017-8046 sid:45976 reference:cve,2018-6577 sid:46062 reference:cve,2018-6578 sid:46062.
Explanation:for eample sid:45917 there are four references they are (reference:cve,2016-10033 reference:cve,2016-10034 reference:cve,2016-10045 reference:cve,2016-10074), we need to split each reference and append sid one below the other (note: sid is always followed by reference), like this there are repetitive blocks, so if there are multiple references we need to append them in New file order.