Sed replace pattern with line number

后端 未结 7 2248
南方客
南方客 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:44

    one-liner to modify the FILE in place, replacing LINE with the corresponding line number:

    seq 1 `wc -l FILE | awk '{print $1}'` | xargs -IX sed -i 'X s/LINE/X/' FILE
    

提交回复
热议问题