Awk Question

Ben Walton bdwalton-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Mon Oct 29 19:21:56 UTC 2012


> END {
>     for (u in Users) {
>         split (u, parts, SUBSEP);

You should likely iterate[1] over Privs first, skipping any priv that
you don't care about.  Then, iterate over the user array for each
username found holding the desired privilege.  That avoids even
looking at users that don't hold the desired privilege.

>         if (parts[2] == "Delete") {
>             print parts[1];
>             for (p in Privs) {
>                 split(p, privparts, SUBSEP);
>                 if (privparts[2] == parts[1]) {
>                     print privparts[1];
>                 }
>             }
>         }
>     }
> }


HTH.

Thanks
-Ben

[1] Because multidimensional arrays are simply concatenated keys
stuffed in a single array element, you will need to iterate...unless
there is a saner way that I'm not aware of.

-- 
---------------------------------------------------------------------------------------------------------------------------
Take the risk of thinking for yourself.  Much more happiness,
truth, beauty and wisdom will come to you that way.

-Christopher Hitchens
---------------------------------------------------------------------------------------------------------------------------
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list