#!/bin/bash

#INPUT	
#		$1, the IP address for clear if provided, else cleal all arp entries
#DESC
#		clear the arp but not include the incomplete entries
#CALLER
#		xorpsh.cmds
#RETURN
#		0

if [ ! -z $1 ] ; then 
    sudo arp -n | \grep -v incomplete | sed 's+^.*(++' | tr -d ')' | awk '/[0-9]/ {print $1}' | \grep "$1"
    if [ "$?" = 1 ]; then 
        echo "No ARP entry for $1"
    else
        sudo arp -d $1
    fi
else
  sudo arp -n | \grep -v incomplete | sed 's+^.*(++' | tr -d ')' | sudo awk '/[0-9]/ {system("arp -i "$(NF)" -d "$1) }'
fi

exit 0
