bowei_99 has asked for the wisdom of the Perl Monks concerning the following question:
change to:server old-ip-or-hostname-here prefer [burst iburst]
change to:server new-ip-here prefer burst iburst server another-ip-or-hostname-here [burst iburst]
as well as, in some cases,nothing (remove the line)
occurs, and it should be leave as is, i.e. no change.server 127.127.1.0
So, I try the following for the first:
but I'm not sure how to write the regexp for the second without removing lines for 127.127.1.0.perl -p -i -e 's/server [\w\.]+ prefer.*/server new-ip-here prefer bur +st iburst/g' ntp.conf
I'm running this from a shell script, so to keep it simple, I'd like to keep it as a perl one-liner. Also, for the second replacement, it could be pretty much any IP address or hostname; I'd rather not go through all my systems to build a regexp of all the possible values.
Any thoughts on how to write the second regexp?
-- Burvil
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regexp to exclude one IP and get all others?
by moritz (Cardinal) on Apr 15, 2010 at 19:08 UTC | |
Re: Regexp to exclude one IP and get all others?
by kennethk (Abbot) on Apr 15, 2010 at 19:25 UTC | |
by bowei_99 (Friar) on Apr 15, 2010 at 20:07 UTC |