Sed executes multiple commands on the same match

because sed outputs all the data rows by default, sed"s pattern/command" a pattern/command" GO process, and the data that is not matched is output normally
I want to continue editing the rows that have just been matched after sed executes a"/ pattern/command" command, and finally no matching data can still be obtained
if there is no pipeline function inside sed. Only sed-e"/ pattern/command1"
-e"/ pattern/command2"-e"/ pattern/command3"
rematch the pattern every time

for example, I want to do the following:
Start file:

/Page0
SSD_Single(0xE0,0x00);

//--- PASSWORD  ----//
SSD_Single(0xE1,0x93);
SSD_Single(0xE2,0x65);
SSD_Single(0xE3,0xF8);

End file:

//Page0
data_arry[0] = 0x00E01500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(1);

//--- PASSWORD  ----//
data_arry[0] = 0x93E11500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(1);
data_arry[0] = 0x65E21500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(1);
data_arry[0] = 0xF8E31500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(1);
data_arry[0] = 0x03801500;
dsi_set_cmdq(data_array, 1, 1);
MDELAY(1);

I currently use this script:

    cat "${file}" | sed -r "
        s/^\s*\|\s*$//g
        s/^SSD_Single.*0x(.*),0x(.*)\);/0x\2\11500/
        s/^0x.*/data_arry[0] = &;/g
        /data_arry.*/a\dsi_set_cmdq(data_array, 1, 1);\nMDELAY(1);
        "

notice the commands on lines 2-4 of sed. In fact, lines 2-4 process the same row of data, but in lines 3 and 4, the commands have to match 0x and data_arry to process the same line. I hope to continue to execute multiple commands on the matching line after a match.

Jul.07,2022

cat "${file}" | sed -r -e '
        s/^\s*\|\s*$//g
        s/^SSD_Single.*0x(.*),0x(.*)\);/0x\2\11500/
        /^0x.*/{s//data_arry[0] = &;/;a\dsi_set_cmdq(data_array, 1, 1);\nMDELAY(1);' -e '}
        '

I see. Thank you


how to solve it. Could you please give me a specific look? I understand that-e also performs two matches

Menu