Match a string that contains a newline using sed

后端 未结 4 1257
灰色年华
灰色年华 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:21

    try this line with gawk:

    awk -v RS="\0" -v ORS="" '{gsub(/\t#\n\tpap/,"yourNEwString")}7' file
    

    if you want to let sed handle new lines, you have to read the whole file first:

    sed ':a;N;$!ba;s/\t#\n\tpap/NewString/g' file
    

提交回复
热议问题