We have megaease.conf, and want to replace the contents in user.conf between the ######### MEGAEASE-BEGIN ########## and ######### MEGAEASE-END ########## lines.
First time, insert the block
echo "######### MEGAEASE-BEGIN ##########" >> user.conf
cat megaease.conf >> user.conf
echo "######### MEGAEASE-END ##########" >> user.confThen, update the block with new configuration
awk 'FNR==NR{ _[++d]=$0;next}
/######### MEGAEASE-BEGIN ##########/{
print
for(i=1;i<=d;i++){ print _[i] }
f=1;next
}
/######### MEGAEASE-END ##########/{f=0}!f' megaease.conf userr.conf > user.new.conf