bergman on 13 Nov 2011 06:25:05 -0800 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] Finding a /etc/group entry containing a user list |
In the message dated: Sun, 13 Nov 2011 14:10:49 +0100, The pithy ruminations from sean finney on <Re: [PLUG] Finding a /etc/group entry containing a user list> were: => On Sat, Nov 12, 2011 at 02:54:13PM -0500, JP Vossen wrote: => > But the original point is, I don't know what group to use. I'm => > looking for the group that already contains the most members of my => > list, so that a) I don't need to create a new group and b) I need to => > add the fewest users to that group to that it contains everyone from => > my list. => => something like this? => => for group in `groups $users | cut -d: -f2-`; do => echo $group => done | sort | uniq -c | sort -n Nice... or slightly more compact: groups $users | cut -d: -f2-|tr " " "\012" |sort | uniq -c | sort -nr I haven't had coffee yet this morning, so I'm not ready to think in 'awk', but I'm sure the the process could be reduced to: groups $users | awk '{some hideous expression}' It's like playing "Name That Tune" with command pipelines...can a process be done with fewer fork()s? Mark => => => :) => => sean ___________________________________________________________________________ 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