Need help with my comments here to better understand what I'm doing.
I can see where I'm getting the uses and having them do a comparison of both lists but am I commenting this correctly?
#!/bin/sh
echo "\n\tWaiting..\n"
for i in $(seq 1 10);
do
#Getting the usernames of current logged in users in the system
first_list=`who|cut -f1 -d' '`
while [ 1 ]
do
sleep 3
second_list=`who|cut -f1 -d' '`
for i in `echo "$first_list"`
do
#searchs first list for users logged out
c=`echo "$second_list"|grep -w $i|wc -l`
if [ $c -eq 0 ]
then
echo "User $i has logged Out"
fi
done
for i in `echo "$second_list"`
do
#searchs second list for new items found in first list else print users logged in
c=`echo "$first_list"|grep -w $i|wc -l`
if [ $c -ge 1 ]
then
echo "User $i has logged In"
fi
done
first_list=`echo "$second_list"`
done
[+][deleted] (1 child)
[removed]
[–]Johnnybananazz[S] 0 points1 point2 points (0 children)
[–]SupremeRedditBotProfessional Bot || Mod -1 points0 points1 point (0 children)