I have some configuration files that basically look like
(...content...)
# BEGIN DYNAMIC BLOCK - DO NOT EDIT MANUALLY
(... more content ...)
# END DYNAMIC BLOCK
(... even more content ...)
Now, in bash using CONTENT=`wget -O - http://$SERVER/get_config.php`
, I have the replacement for the dynamic block.
How do I do the replace now and how do I make the script insert the block at file's end if it isn't there?
Best Answer
If you want to use sed, you can read from a named pipe. Beware that this code doesn't try to cope with errors. The script will block if the dynamic block header is present more than once.
But I'd go for awk.