#!/bin/bash set -eu embed() { local tag="$1" local find="$2" local sourcefile="$3" while IFS= read -r line ; do if [[ "${line}" =~ "${find}" ]] ; then echo -n "<${tag}>" cat "${sourcefile}" echo -n "" else echo "${line}" fi done } embed "$@"