find matching text and replace next line

前端 未结 3 1520
北恋
北恋 2020-12-02 22:01

I\'m trying to find a line in a file and replace the next line with a specific value. I tried sed, but it seems to not like the \\n. How else can this be done?

The f

3条回答
  •  遥遥无期
    2020-12-02 22:39

    This might work for you (GNU sed):

    sed '/ConnectionString<\/key>/!b;n;cchanged_value' file
    

    !b negates the previous address (regexp) and breaks out of any processing, ending the sed commands, n prints the current line and then reads the next into the pattern space, c changes the current line to the string following the command.

提交回复
热议问题