[TriLUG] possible awk/grep question

Craig Taylor ctalkobt at gmail.com
Sun Dec 30 19:42:05 EST 2007


I thought about the awk route also but decided to go after your intent
instead of your algorithm :-)

Generally, checking for 100 as the primary user group (the 4th column) will
work but for the fact that users can belong to multiple groups and the users
group may not always be 100 (generally is however).   I'm not sure how
wide-spread you'll be using the script so decided to err on the side of
caution...

On Dec 30, 2007 6:38 PM, Joseph Mack NA3T <jmack at wm7d.net> wrote:

> On Sun, 30 Dec 2007, Craig Taylor wrote:
>
> > As with anything else in Linux, there's a million ways...
> >
> > for USR in `cat /etc/group | grep ^user | sed "s/^.*:100://" | sed "s/,/
> > /g"`; do
> >    echo $USR
> > done
>
> Hi Craig,
>
> thanks for the suggestion
>
>        Having thought about this for a week or so now, and
> not having an answer, after posting here, I googled and came
> up with
>
> cat /etc/passwd | awk 'BEGIN { FS = ":" } $4 == "100" {print}'
>
> I didn't know about the
>
> $4 == "100"
>
> construct
>
> Joe
>
> --
> Joseph Mack NA3T EME(B,D), FM05lw North Carolina
> jmack (at) wm7d (dot) net - azimuthal equidistant map
> generator at http://www.wm7d.net/azproj.shtml
> Homepage http://www.austintek.com/ It's GNU/Linux!
> --
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
>



More information about the TriLUG mailing list