Use
sed '/#start/,/#end/replace_command'
For example, if the file is called myconfig, and you want to replace "allow" with "deny" in that section, you could say
sed '/#start/,/#end/s/allow/deny/' myconfig
example
sed -i -r "/<elasticConfig>/,/<\/elasticConfig>/s,<enabled>.+</enabled>,<enabled>false</enabled>," file.xml
Via sametmax
If you’d like to prevent daemons from starting after installing a package, just toss a few lines into /usr/sbin/policy-rc.d:
cat > /usr/sbin/policy-rc.d < < EOF
echo "All runlevel operations denied by policy" >&2
exit 101
EOF