#!/bin/sh delim_begin="$1" delim_end="$2" contents_file="$3" dest="$4" sed -i -ne "/$delim_begin/ {p; r $contents_file" -e ":a; n; /$delim_end/ { p; b}; ba}; p" "$dest"