Sed replace pattern with line number

后端 未结 7 2208
南方客
南方客 2021-01-05 03:53

I need to replace the pattern ### with the current line number.

I managed to Print in the next line with both AWK and SED.

sed -n \"/###/{

7条回答
  •  迷失自我
    2021-01-05 04:31

    This might work for you (GNU sed):

    sed = file | sed 'N;:a;s/\(\(.*\)\n.*\)###/\1\2/;ta;s/.*\n//'
    

提交回复
热议问题