solved
who | grep -w ^$user >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo "$user is online"
else
echo "$user not online"
fi
if your grep supports -q option, use it like this who | grep -qw "^$user"
--ahamed
1 Like
even more streamlined.
if who|grep -qw ^$user >/dev/null 2>&1
then
echo "$user is online"
else
echo "$user not online"
fi
or the one line version.
who|grep -qw ^$user && echo "$user online" || echo "$user not online"
1 Like
gah I should have known to pipe grep I completely forgot
still learning. . .
thanks guys:)