Say I want to automatically update my
/etc/ntp.conf configuration using
sed. Format of
ntp.conf allows to define lists by usage same keywords for lines occurred all over the file. For example:
# first block occurrences server 220.127.116.11 server 18.104.22.168 driftfile /var/lib/ntp/drift # second block of occurrences server 22.214.171.124 server 126.96.36.199
Now, I've got updated list of
ntp servers, say 188.8.131.52, 184.108.40.206 and 220.127.116.11. As a result I want to get:
# first block occurrences server 18.104.22.168 server 22.214.171.124 server 126.96.36.199 driftfile /var/lib/ntp/drift # second block of occurrences
Can I do it with
sed? Is it right tool for this problem or should I use something else?
P.S.: commenting out second block (or both) of occurrences could also be an option.