我正在尝试从 $countip 中提取最高数字并将其复制到 $totalip,问题是 $totalip 总是返回 0。任何人都可以帮助我,我是 bash 脚本的新手。
for srcip in `cat /var/log/messages | grep "WACSLAW1 CRITICAL INCOMING" | awk '{ print $14 }'|grep -v 192.168.1. |grep -v IN=eth1 |grep -v MAC`;do
if (! grep "$srcip" /var/wacstemp/ids.tmp > /dev/null) ; then
countip=0
echo $srcip >> /var/wacstemp/ids.tmp
else
countip=`expr $countip + 1`
if [ $countip -gt $totalip ];
then
# echo $countip
countip=$totalip
# echo $totalip
fi
fi
done