assistunix
asked on
Aix unix last login need assistance with writing script ksh
I need help writing a script to generate list of last login of all users in a server.
user's information is in /etc/passwd file and the command to list the last login of a user is "last username -n 1".
How can i put those two steps together in a script to get the output of last login of all users?
user's information is in /etc/passwd file and the command to list the last login of a user is "last username -n 1".
How can i put those two steps together in a script to get the output of last login of all users?
Or if you want details for all users, in /etc/passwd file order, and not just those who've logged in try:
finger -sm root | egrep '^Login';(for user in `cat /etc/passwd | cut -f1,1 -d: `; do finger -sm $user 2>/dev/null; done) | egrep -v '^Login'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both.
arober11: your finger command syntax doesn't work right, give's an odd output. your last command only provides the listing of the user that i am logged in as, instead of all the users.
wmp: your command works like magic.
arober11: your finger command syntax doesn't work right, give's an odd output. your last command only provides the listing of the user that i am logged in as, instead of all the users.
wmp: your command works like magic.
wmp