When a user last logged in

Hello!

what command or script would I use so that when a user logs in, it will display the last time that user logged in to the system. Only thing I can get close is 'finger -l root' but that only does for when root logs in and adding it to /etc/profile will only show the last time 'root' logged in, even if you log in with another username. I want to use a variable like $USER for example, so it will check the log file '/var/adm/lastlog'. I've spent hours on this one. Man pages, internet and all. I'm stumped on this one.

Cheers,

Nigel

[580 byte] By [jonny_crane] at [2007-11-25 23:36:09]
# 1
use last!e.g. last -n 2 $LOGNAME| tail -1you could then pass it through to cut or awk to just grab the details you want to be a little bit clever.
AlanRice at 2007-7-5 18:20:31 > top of Java-index,General,Talk to the Sysop...
# 2
THANK YOU!!!! I couldn't think what the variable was for user. I haven't done awk before so thats where I was lost.Cheers!
jonny_crane at 2007-7-5 18:20:31 > top of Java-index,General,Talk to the Sysop...