I have a file which contains data as below, there is 2 keywords, current_area {data1/data2/code..}, current_area {data1} and some data between those:
current_area {data1/data2/codeA..}
do_this {data}
do_this {data}
current_area {data1}
current_area {data1/data2/codeB..}
do_this {dataX}
do_this {dataY}
current_area {data1}
I want to arrange it such that for all the “do_this” between their set of current_area {data1/data2/code..} and current_area {data1} have the code part come in do_this, like :
current_area {data1/data2/codeA..}
do_this {codeA../data}
do_this {codeA../data}
current_area {data1}
current_area {data1/data2/codeB..}
do_this {codeB../data}
do_this {codeB../data}
current_area {data1}
I have tried with sed but I am lost on the algo here.
I thought to replace the current_area with do_this only.
sed ‘s@current_area {data1/data2/@do_this {‘ file, but that only makes the whole file with do_this