[aklug] Re: Question about awk

From: Joshua J. Kugler <joshua@eeinternet.com>
Date: Wed Sep 22 2010 - 15:45:36 AKDT

So, here's what the guys on #awk came up with:

users=`awk -v min="$MIN" -v
okuser="$OKUSERS" -F: 'BEGIN{split(okuser,a,/,/);for (i in a) b[a[i]]}
($3 < min) && !($1 in b){printf "%s%s",s,$1;s=","}' /etc/passwd`

That's all one line of course.

j

On Wednesday 22 September 2010, Joshua J. Kugler elucidated thus:
> MIN=1000
> OKUSERS='(www-priv,www-data)'
>
> # This is all one line
> users_to_ignore=`cat /etc/passwd | awk -F":" '{if ($3 <'$MIN'
> && "'$OKUSERS'" !~ /\W$1\W/) print $1 ","}' | xargs -i echo -n {}`
>
> echo users_to_ignore
>
> This is printing all the users with UIDs below 1000.
>
> What small thing am I missing so it will not include users in OKUSERS
> in its final output?
>
> j

-- 
Joshua Kugler
Part-Time System Admin/Programmer
http://www.eeinternet.com - Fairbanks, AK
PGP Key: http://pgp.mit.edu/  ID 0x73B13B6A
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Sep 22 15:45:51 2010

This archive was generated by hypermail 2.1.8 : Wed Sep 22 2010 - 15:45:51 AKDT