The
if grep abcdefgh.was.tb.dsdc /tmp/hosts part checks if the string is present, you need to know if the string is not present.
Try this:
Code:
if ! grep abcdefgh.was.tb.dsdc /tmp/hosts
then
. /tmp/1 && sed -i "s/^$IP$/$IP $WAS_HOSTNAME/" /tmp/hosts
fi
I also changed your sed statement, yours seems to elaborate.