Given is input_file:
1
2
START
foo
END
3
Goal is to replace content inside including START ... END block with multi-line content from stdin:
1
2
hello
world
3
What I tried:
sed '/^START$/,/^END$/d;r /dev/stdin' input_file <<EOF
hello
world
EOF
unfortunately results in
1
hello
world
2
3
I guess r /dev/stdin is invoked sequentially after /^START$/,/^END$/d; and just appends after first line.
Second try:
sed '/^START$/,/^END$/{d;r /dev/stdin
}' input_file <<EOF
hello
world
EOF
prints
1
2
3
Why do above commands - especially last one - do print the wrong result? And how might I adjust these?