Does anyone know what pipe string might be used to determine how many people are logged onto an AIX system where a group ID begins with lets say 4.
In other words, I am looking to query the system for the number of people currently logged onto a system that belong to any group starting with 4. Could be 400, 4102, 444, etc.
This will give you a list of users and gid starting with 4 - modify it for your needs ( sorry it's what I use to write scripts in).
#!/bin/csh
set allusers="`who -q`"
foreach xx ($allusers)
if ("$xx" == "#") then
exit
else
# find info on user
set mygid=`grep $xx /etc/passwd|awk -F: '{print $4}'`
if ("$mygid" != "") then
set first=`echo $mygid|awk '{print substr($0,0,1)}'`
if ("$first" == "4") then
# let me know who
echo $xx" "$mygid
endif
endif
endif
end
Also note it will only give you folks that are in the password file - if you're using NIS, you would have to change where it's looking.