多行 regexp 替换为无条件分支

假设我有一个名为 in.txt 的文件:

$ cat in.txt
a
b
a
c
a
d

我只想用 deleted 替换 a\nc,而不是 a\nba\nd

$ sed -e ':loop         # create a branch/label named `loop`
 $!{
 N                      # append the next line of input into the pattern space
 /\n$/!b loop           # If it is not the last line go to the `loop` branch again
 }
 s/a\nc/"deleted"/' in.txt    # do replacing in the pattern space

a
b
"deleted"    # see! succeed
a
d