when I run this script:
Code:
trythisvar=$(sudo ufw status verbose | tr -d -c [:alpha:])
echo $trythisvar
if "$trythisvar" = "some dumb string"
then echo "The damn thing's alive!"
else echo "No, it doesn't equal that."
fi
in a terminal I get this output:
Code:
me@me-dt:~$ /home/me/0_my_stuff/scripts/ufw-testing-UNFINISHED/trythis.sh
Statusinactive
/home/me/0_my_stuff/scripts/ufw-testing-UNFINISHED/trythis.sh: line 3: Statusinactive: command not found
No, it doesn't equal that.
me@me-dt:~$
which seems to indicate that in line 3 the expansion of trythisvar is treated as a command despite being enclosed by double quotes and appearing in the context of a string comparison. Would someone mind giving me a hint why this is so? Thanks for your time to read this, even if you are as puzzled as I am, which isn't likely.
Bookmarks