Re: little awk question

Jon Ruano <[email protected]> Sun, 30 Jul 2006 13:03:01 +0200
Newsgroups gmane.network.toolmakers
Message-ID <[email protected]>
Hello,

Most of the syntax awk I learned was when fiddling with the =20
filter_audit file :)
Basically, I added different situations where a route-map can be =20
found as a reference (for instance, neighbor unsuppress-map, =20
redistribute ospf n route-map, redistribute rip route-map ...)

Your idea looks pretty useful to match all the references to route-=20
maps in one group (I've been writing ones for every specific case =20
that I found in our routers config.)

After playing a bit, there's a way (although maybe not very elegant =20
anyway). You know the previous term to the one you're looking for is =20
"route-map". So why not traversing the line and take the NEXT term:

/^ .* route-map / {
   cur =3D 0;
   while ( cur <=3D NF ) {
      if ( $cur =3D=3D "route-map" ) {
        cur++;
        ref[router " route-map " $cur] =3D 1;
        next;
      }
      cur++;
   }
   next;
}


Jon

P.S.: It's good to see emails coming from this so-low-trafficked =20
mailing list. In fact, I didn't remember I had signed up ;-)