I have problem with this script
The Output is always "Your string has been found" even if there isn't anything in /etc/hosts. Do you have any ideas how to solve this problem or is it even possible to do this?
Any feedback is appreciated. I'm beginning to learn bash so feel free to critize me.
Thank you.
#!/bin/bash
google= dig +noall +answer www.google.com | awk '{ print $1, $NF }'
hosts= cat /etc/hosts | grep "www.google.com"
if [ $google == $hosts ] ; then
echo "Your string has been found"
else
echo "Your string has not been found"
fi