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 188.8.131.52 server 184.108.40.206 driftfile /var/lib/ntp/drift # second block of occurrences server 220.127.116.11 server 18.104.22.168
Now, I've got updated list of
ntp servers, say 22.214.171.124, 126.96.36.199 and 188.8.131.52. As a result I want to get:
# first block occurrences server 184.108.40.206 server 220.127.116.11 server 18.104.22.168 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.