On Tuesday 15 October 2002 01:05 pm, Bret is done writ:
<snip>
> have been working with awk lately and this seems a good time for it.  
<snip>
And then..the script:

BEGIN {
#  set the variables for the address change
# * * * * * * * * * * * * * * * * * * * * * * * * 
#    Make sure you leave the $ at the end of the oldip address
# to take care of the situation where the last octet is less thatn
# three digits in decimal   

Not necessary.
# * * * * * * * * * * * * * * * * * ** * * * * *     

#    oldip="192.168.0.13$" changed to below
    oldip="192.168.0.13"
    newip="192.168.0.123"
}
{
# increment the serial number which should be the line directly below
# the SOA line
   if ($0 ~ /SOA/) {
      print;        
      getline;
      ser_no = $(1);
      restofline = substr( $0, index( $0, /;/ ) + 1); # get rest of line
      print "\t\t\t\t" ++ser_no restofline;
   }
   else {
      if ( $0 ~ oldip))
         gsub(oldip,newip);
      print
   }
}

        mark (yes, I *am* an awk guru)
-- 
"Some of this so-called free speech today is actually 
 enemy combatants against the Republican Party."
    - in the mouth of Ashcroft, Ray Berry, BushToons



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to