My input file contains data as below
acb/xyz/row<t>
acb/xyz/row<t>
abc/xyz/row<b>
abc/xyz/row<b>
abc/xyz/row<0>
abc/xyz/row<0>
abc/xyz/row<1>
abc/xyz/row<1>
abc/xyz/row<2>
abc/xyz/row<2>
abc/xyz/row<3>
abc/xyz/row<3>
abc/xyz/row<4>
abc/xyz/row<4>
So I want the output to be as shown below:
#Sector Top
acb/xyz/row<t>
acb/xyz/row<t>
#Sector Bottom
abc/xyz/row<b>
abc/xyz/row<b>
#Sector 0
abc/xyz/row<0>
abc/xyz/row<0>
#Sector 1
abc/xyz/row<1>
abc/xyz/row<1>
#Sector 2
abc/xyz/row<2>
abc/xyz/row<2>
#Sector 3
abc/xyz/row<3>
abc/xyz/row<3>
#Sector 4
abc/xyz/row<4>
abc/xyz/row<4>
- Each sector shown above contains multiple lines, here I have shown only 2 lines per sector.
- There are top, bottom and from 0 to 30 sectors, here I have shown up to 4 sectors.
I tried for one of the sectors by using sed command as:
sed '/row<1>/i #Sector 1' myfile
which gives me output like:
#Sector 1
abc/xyz/row<1>
#Sector 1
abc/xyz/row<1>
I don't need a new line before every match, only needed before first match for all the sectors.