[TriLUG] possible awk/grep question

David Black dave at jamsoft.com
Sun Dec 30 19:49:18 EST 2007


If a user means their default group is 100 - for fun, here's a variation
using bash alone:

#!/bin/bash
IFS=':\n'
(while read USR F2 F3 GID F5; do
        if [ $GID -eq 100 ]; then
                echo $USR
        fi
done) < /etc/passwd

Dave

Joseph Mack NA3T wrote:
> I need to find all "users" on a machine.
>
> It occurs to me that I could find this by looking for all 
> lines in /etc/passwd that have "100" in the 4th field, but I 
> don't know how to do that in bash/awk/grep, at least not in 
> a small number of lines. If I can do that, then I have other 
> uses for a script that can find all lines that match in a 
> certain field. Anyone know how to do that?
>
> Failing that, anyone know how to find the members of a group 
> (eg users) by any method?
>
> Thanks Joe
>
>   



More information about the TriLUG mailing list