如何完成这样的比较?
同一个用户再次登录,他就不显示有登录了,求求!
a=`date`
b=`who|awk '{printf $1 "\n"}`
echo "$b\n" > b.txt
while [ 1 -lt 2 ]
do
echo "The current time is :$a"
echo "The current users are :$b"
sleep 30
c=`who|awk '{printf $1 "\n"}`
echo "$c\n" > c.txt
echo `awk '{print $0}' b.txt c.txt|sort|uniq -u` > tmpfile
d=`cat tmpfile|grep -v ^$|wc -l`
if [ $d -eq 0 ]
then
echo "no user login and logout"
else
i=1
while [ i -le $d ]
do
e=`cat tmpfile|awk '{printf $0 " "}'|awk '{printf $k}' k="$i"`
if [ `cat b.txt|grep $e|wc -l` -eq 0 ]
then
echo "user login:$e"
else
echo "user logout:$e"
fi
let i=i+1
done
fi
echo "$c\n" > b.txt
done
```bash
```
```bash
#! /bin/sh
while true
do
who | cut -d " " -f1 | sort> old.txt
sleep 3
who | cut -d " " -f1 | sort> new.txt
comm old.txt new.txt -2 -3 >> logOneTime.txt
comm old.txt new.txt -1 -3 > newLog.txt
num=0
cat newLog.txt | while read line
do
if grep $line['-'] user.deny>/dev/null
then
if grep $line logOneTime.txt>/dev/null
then
fullName=`grep $line['-'] user.deny | cut -d "-" -f2`
num=`expr $num + 1`
echo -e "The user $fullName (on the denial list) has logged in more than once!\n"
fi
fi
done
if [ $num -eq 0 ]
then
echo -e "No user on the user.deny list has multiple logins\n"
fi
done
while true
do
```