in reply to Regexp to exclude one IP and get all others?

So you want something that will match server another-ip-or-hostname-here [burst iburst] for all values of another-ip-or-hostname-here except 127.127.1.0 and doesn't match if the line includes prefer, wiping the line on match? You can accomplish this fairly easily with negative look-ahead assertions.

perl -p -i -e 's/server (?!\Q127.127.1.0\E)[\w\.]+\s+(?!prefer).*//g' ntp.conf

See perlretut for more info. And might I suggest -i.bak in place of -i?

Replies are listed 'Best First'.
Re^2: Regexp to exclude one IP and get all others?
by bowei_99 (Friar) on Apr 15, 2010 at 20:07 UTC
    Thanks. That works. :)

    -- Burvil