|Rich Freeman on 12 Nov 2011 13:02:04 -0800|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|Re: [PLUG] Finding a /etc/group entry containing a user list|
On Nov 12, 2011 2:28 PM, "JP Vossen" <firstname.lastname@example.org> wrote:
> I thought of chaining a bunch of greps together, but that's ugly, not scalable, and won't give me a list of partial matches.
How about this (typing on phone so can't debug much). Put list of users in a file, one per line. Feed one line of group at a time into grep -o -f userlist -c (or pipe into wc -l if the -c isn't right) to get a per-line count. Probably a little xargs and a function or script to split the groups, and maybe a little awk to print the group names.
You should be able to do it in a few lines, maybe something for the next revision of your book. :)
That should scale fine until you hit the need for btree indexes or whatever...
___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug