Skip to content

Instantly share code, notes, and snippets.

@aarohmankad
Created April 19, 2019 04:55
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 aarohmankad/9562f89d71fd26c04a9474b8777e209e to your computer and use it in GitHub Desktop.
Save aarohmankad/9562f89d71fd26c04a9474b8777e209e to your computer and use it in GitHub Desktop.
#!/bin/bash
users=($(cat /etc/passwd | awk -F":" '{print $1}'))
uids=($(cat /etc/passwd | awk -F":" '{print $3}'))
for i in "${!users[@]}"; do
groups=($(cat /etc/group | grep "^${users[i]}" | awk -F":" '{print $4}'))
echo ${users[i]} ${uids[i]} $groups
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment