Skip to content

Instantly share code, notes, and snippets.

@drewchapin
Created February 18, 2018 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drewchapin/80db40d5db63723f3cff101eb08da535 to your computer and use it in GitHub Desktop.
Save drewchapin/80db40d5db63723f3cff101eb08da535 to your computer and use it in GitHub Desktop.
List users of a the specified group(s).
#!/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