Alex & Stevens, et al -- ...and then Stevens said... % % On 02/15/2018 06:09 AM, Dave Howorth wrote: % >On Thu, 15 Feb 2018 11:07:55 +0100 % >Alex Naumov <alexander_naumov@opensuse.org> wrote: % > % >>can someone tell me how to get users list of some primary group. ... % >>needing to parse files. % > % >I don't think there's a simple answer. Search unix.stackexchange to see % >what's possible. I am inclined to agree; there is no simple and easy program that tells you that. You're gonna be parsing files. % % A stupidly simple but not terribly accurate answer is: % #> less /etc/passwd |grep <users group number> % % I say not terribly accurate because in my system, users group is 100 % and grep returns not only 100 but anything with 100 in it. You did % say without parsing files. That is as close as I can get without % more coffee. Well, the easy fix for this is to anchor the pattern. Something like grep ":100:" /etc/passwd (BTW, you don't have to cat or less through grep) will exclude 1100 and 1000 and so on. Unfortunately, it will also give you the user 100. The only way to limit to groups is to look at the GID field. To avoid hard-coding the GID, you should first check in the /etc/groups file to see what it is. Realistically this is pretty easy to dash off in a one-liner (with a placeholder var to make it easy; if it were a shell script you'd take the group name as input): G=groupname awk -F: -vGID=`egrep "^$G:" /etc/group | cut -d: -f3` '{if ($4==GID) print $1}' </etc/passwd Season to taste :-) I'd be VERY interested in how this could be condensed, by the way! HTH & HAND :-D -- David T-G See http://justpickone.org/davidtg/email/ See http://justpickone.org/davidtg/tofu.txt -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org