Perl - Insert lines after a match is found in a file

前端 未结 5 1684
南笙
南笙 2021-01-24 09:34

I have a file with the following syntax in some_1.xyz

module some_1 {
INPUT PINS
OUTPUT PINS
}

and I want to insert APPLY DELAYS xx and APPLY L

5条回答
  •  盖世英雄少女心
    2021-01-24 10:11

    Something much simpler, in just one line using SED (in case this question is for UNIX only and when the match is a fixed value, not regular expression):

    sed -i -e "s//\n/g" file.txt
    

    (The options have been swapped compared to the initial response, because the first comment.)

    Notice the \n is to add a new line. Regards

提交回复
热议问题