This is more a comment on the mikeB answer, but comments don't allow code so I'll post it as an answer:
You can use something like grep to find what you're looking for, such as
ip addr show dev eth0 | fgrep -q 'inet 192.168.1.1'
if [ $? -eq 0 ]; then
echo 'IP found'
else
echo 'IP not found'
fi
This can actually be simplified getting rid of the test ( [ is an alias for test) on the exit status, because if already checks exit status directly, which is how test communicates with if already:
if
ifconfig | fgrep -q 'inet 192.168.1.1'
then
echo "IP Found"
else
echo "IP Not found"
fi
And you can further simplify this by using the regex searches built into most bourne shells by using a case statement:
case $(ifconfig)
in
*"inet 192.168.1.1"*)
echo "IP found"
;;
*)
echo "IP not found"
;;
esac