Replace a word with multiple lines using sed?

前端 未结 9 1682
礼貌的吻别
礼貌的吻别 2020-11-27 06:32

I\'m working on a bash-script that has to prepare an E-Mail for being sent to a user.

It aggregates some data, which ends up being multiple lines of stuff. For the e

9条回答
  •  日久生厌
    2020-11-27 06:57

    Not sure if you have tried to put "\n" in the replace part

    sed 's/[pattern]/\
    [line 1]\n\
    [line 2]\n\
    [line n]\n\
    /g' mail.tpl
    

    The first line has /\ for readibility reasons. Each line after that is a stand-alone line like you would find in a text editor. Last line is stand-alone, once again for readability reasons. You can make all of this one line if needed. Works on Debian Jessie when I tested it.

提交回复
热议问题