Monday, 2 April 2018

Shell script to display user login time

#Script  to display the time at which specified user logged in
un=$1
t=`who | grep "$un" | head -1 | tr -s " " | cut -d ' ' -f 4`
echo "User $un has logged in at $t time"



OUTPUT
csc@csc-SVE1513CYNB ~ $ sh logTime.sh csc
User 'csc' has logged in at time 02:13



No comments:

Post a Comment