Sat 18 Sep 2010
One liner of the week
Posted by Craig under Geek
No Comments
How to find new or re-activated accounts in NIS in the past week:
d=`date +%Y%m%d -d '7 days ago'`; rcsdiff -r`rlog -d$d /var/yp/source/passwd |grep "^revision"|awk '{print $2}'` /var/yp/source/passwd|sed 's/^[<> ]//; /---/d; /^[0-9]/d'|perl -F: -walne '$h{$F[2]}.="$F[0] "; END {$h{$_} =~ / ./ && print "$_: $h{$_}" for keys %h}' | awk '{ if ( $NF !~ /_[a-z]+/ ) { print $NF } }'
And yes, I know this will also pick up accounts with changed passwords, I don’t mind that.


Twitter