RE: little awk question

"Yuval Ben-Ari" <[email protected]> Sun, 30 Jul 2006 16:10:28 +0200
Newsgroups gmane.network.toolmakers
Message-ID <58D14E53A4F69C4EAF4D29171C447CC491FA9C@NTX-CL.forest.netvision.net.il>
> Hello,
>=20
> 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 ...)
>=20
> 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.)
>=20
> 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:
>=20
> /^ .* 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;
> }
>=20
>=20
> Jon
>=20
> 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 ;-)

Yes, that should work.
I think I found another way:

/^ .* route-map / {
  match($0, /route-map ([A-Za-z0-9_\-]+)/, arr);
  ref[router " route-map " arr[1]] =3D 1;
  next;
}

P.S
It is a shame that we will each do the same work on his own.
Did you do many changes in filter_audit.awk file ?
I plan to finish my changes and send to the author so it can be
published as newer version.
I also try to be as reliable to the original as possible.

Yuval