I am trying to extract the highest number from $countip and copy it to $totalip, the problem is that $totalip is allways returning 0. Can anybody help me please, i am new to bash script.
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