Created
February 18, 2018 03:56
-
-
Save drewchapin/80db40d5db63723f3cff101eb08da535 to your computer and use it in GitHub Desktop.
List users of a the specified group(s).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for group in $@; do | |
echo "$group:" | |
users=$(awk -F: "/^$group/{print \$4}" /etc/group | tr , \\n | sort) | |
if [ "$users" != "" ]; then | |
for user in $users; do | |
echo " $user" | |
done | |
else | |
echo " <no users in this group>" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment