Hi,
Yes this can be done:
awk -F: '$4 ~ /\<50\>/ { print $1 }' /etc/passwd
The above line will give you all user in the /etc/passwd file that belong to (primary) group 50. You do need the \< and \> around the 50 (word bounderies) otherwise you will also get false hits (500, 650, 50123 etc).
If this is what you want/need you could make this oneliner do all the work (deleting found users) by extending it to:
awk -F: '$4 ~ /\<50\>/ { print $1 }' /etc/passwd | xargs userdell -r
WARNING: Make sure you test this first and understand what is going on!!!! A mistake could render your box useless. WARNING
Hope this helps.
Last edited by druuna; 03-08-2005 at 09:33 AM.
|