Script No .
Definition:
Write a shell script to check whether the named user is currently logged in or not.
Script:
clear
echo enter the username
read un
who > userfile
a=`grep "$un" userfile`
c=`echo $a | wc -c`
if [ $c -lt 2 ]
then
echo $un Not logged in
else
echo $un is logged in
fi
OR
echo "Eneter the username"
read un
c=`who | grep -c $un`
if [ $c -gt 0 ]
then
echo "User is currently logged in "
else
echo "User is not currently logged in "
fi