#!/bin/bash

trap "exit" SIGINT SIGTERM

echo "starting pretest"
nmap -nsP $1 | grep "^Host " | grep -v "subnet broadcast" > /tmp/nmap2

while true ; do

 echo "starting test `date`"
 nmap -nsP $1 | grep "^Host " | grep -v "subnet broadcast" > /tmp/nmap1
  
 diff /tmp/nmap2 /tmp/nmap1 > /tmp/nmap
 mv /tmp/nmap1 /tmp/nmap2
    
 echo -e `grep "appears" /tmp/nmap | sed -e "s/[a-zA-Z ]//g" | sed -e "s/^>\(.*\)/\\\\\033[1;32mnew:  \1\\\\\033[0m/" | sed -e "s/^<\(.*\)/\\\\\033[1;31maway: \1\\\\\033[0m/" | sed -e "s/^/\\\\\r\\\\\n/"`
     
done