Find all users in group

d
Nombre: belong.sh
Autor: @Tonejito
Visto en Tonejito
#!/bin/sh
#  = ^ . ^ =
#
# ./belong.sh - Get all users in group
# Andres Hernandez (tonejito)
# http://tonejito.blogspot.com:80/
 
SED=/bin/sed
AWK=/usr/bin/awk
GETENT=/usr/bin/getent
 
GROUP=${1}
 
# Find users whose initial login group is $GROUP
$GETENT passwd | awk -F : "\$4==`$GETENT group $GROUP | awk -F : '{print $3}'` {print \$1}"
 
# Find users whose supplementary group is $GROUP
$GETENT group $GROUP | $AWK -F : '{print $4}' | $SED -e 's/,/\n/g'

0 comentarios: