hi I am trying to write a bourne-shell script that takes a name as a parameter and check if the user is logged in and output a message if not.
this is what I got so far but my condition is wrong.
if test "who|grep $1" == "$1" //the problem is that it takes the hole 1st column
then
who|grep $1|awk '{print $5}'
else
echo user not logged in
fi
any help? thanks in advance.
1) Your condition is completely fouled up.
2) Your regex is inaccurate.
3) You’re mixing grep and awk.
4) You’re not quoting your
echoargument.Replacing the first
grepwithawkis left as an exercise for the reader.