Match a string that contains a newline using sed

后端 未结 4 1244
灰色年华
灰色年华 2020-12-11 02:39

I have a string like this one:

    #
    pap

which basically translates to a \\t#\\n\\tpap and I want to replace it with:

4条回答
  •  囚心锁ツ
    2020-12-11 03:18

    This might work for you (GNU sed):

    sed '/^\t#$/{n;/^\tpap$/{p;s//\tpython/}}' file
    

    If a line contains only \t# print it, then if the next line contains only \tpap print it too, then replace that line with \tpython and print that.

提交回复
热议问题