I posted earlier with something similar to this. I am trying to check if a user is online with the command $ ./user mburkhar
which prints out mburkhar is logged on
. My program works correctly but if I just type $ ./user mb
is also states mb is logged on
. What I have is fine, but is there a way to match what the user typed in exactly instead of slightly matching the first 2 characters..?
Here is my program so you can see what I did:
# Check if a user is logged on
if [ -z $1 ] ; then
read user
else
user=$1
fi
if [ `who | cut -d" " -f1 | grep $1` ] ; then
echo "$1 is logged on"
else
echo "$1 is either not valid or logged on"
fi