The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 06-26-2003
RTM's Avatar
RTM RTM is offline Forum Advisor  
Hog Hunter
  
 

Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
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).


Code:
#!/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.