On Tue, 2002-10-15 at 16:09, Mark wrote:
> 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"
> }
Thanks for the clean up. I am certainly not an awk guru but it's nice
to see I was on the right track :)
when I ran the code I sent using sub(oldip,newip) as you suggest,
without the $ end of line placeholder, it changed addresses like
192.168.0.131 to 192.168.0.1231. I will run run your code but assuming
that it works, wy does it and mine did not? Is there some magic in
gsub?
> {
> # 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
This looks like a good idea and I will try to figurout how it works :)
> print "\t\t\t\t" ++ser_no restofline;
I like the increment, is there no easy way to capture the number of tabs
or spaces in the beginning whitespace?
> }
> else {
> if ( $0 ~ oldip))
> gsub(oldip,newip);
> print
> }
> }
>
> mark (yes, I *am* an awk guru)
> --
Cool and thanks again for the feedback. awk get more cool the more I
get into it.
Bret (I am nowhere near guru status :)
--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list