Shell Script- each unique user
Posted
by
Dinis Monteiro
on Stack Overflow
See other posts from Stack Overflow
or by Dinis Monteiro
Published on 2011-01-10T18:42:39Z
Indexed on
2011/01/10
18:53 UTC
Read the original article
Hit count: 230
Hi guys
I need "for each unique user, report which group they are a member of and when they last logged in"
so i have:
#!/bin/sh
echo "Your initial login:"
who | cut -d' ' -f1 | sort | uniq
echo "Now is logged:"
whoami
echo "Group ID:"
id -G $whoami
case $1 in
"-l") last -Fn 10 | tr -s " " ;;
*) last -Fn 10 | tr -s " " | egrep -v '(^reboot)|(^$)|(^wtmp a)|(^ftp)' | cut -d" " -f1,5,7 | sort -uM | uniq -c
esac
My question is: how i can show the each unique user? the script above only show the more recent user logged in the system, but i need all unique users.
anyone can help?
thanks
© Stack Overflow or respective owner