#!/bin/bash

declare -a array1
array1=($(cat /var/log/mail/mail.log.1 /var/log/mail.log | grep "connect from" | grep -v "disconnect" | grep -v "unknown" | grep -v "static" | 	grep -v "fixip" | grep -v "sdsl" | cut -d ":" -f 4 | cut -d " " -f 4 | cut -d "[" -f 1| sort | uniq | egrep "[0-9][-\.][0-9]*\.*\.\.*" | tr '\n' ' ' ))

element_count=${#array1[*]}
countnew=0
for listEntry in ${array1[*]}; do
	echo " $listEntry " >>test.txt
	echo "$(postmap -q $listEntry pcre:/etc/postfix/maps/dynip.pcre)" >>test.txt

	if [ ! -n "$(postmap -q $listEntry pcre:/etc/postfix/maps/dynip.pcre)" ]; then
        echo $listEntry >> tmpFile.tmp
         fi
done
cat tmpFile.tmp

