Similar to how in python you can do 'if letter in string:', I'm trying to imitate this in bash. The code is below:
SYMBOLS="ABC"
msg="alskdfjAasdksdfh!?asdflkjhghrg"
# Loops through each letter in the variable msg individually
for (( i=0; i<${#real_message}; i++ )); do
# Assigns the current letter to the variable
letter="${msg:$i:1}"
# This is the part I have a question about
if [[ $msg == *"$SYMBOLS"* ]]; then
echo "Found."
fi
done
However, the if statement doesn't work. What's supposed to happen is anytime it grabs a character to be stored in the variable 'letter', it should check if that character exists in the variable 'SYMBOLS'.
For example, msg has the character 'A' in it, so when 'letter' iterates through and gets to 'A', it should echo "Found." indicating the if statement works. However, this doesn't work obviously because I'm not understanding something correctly. Just for clarification: it isn't looking for substrings containing "ABC", it's looking for either "A", "B", or "C" when it's stored in the 'msg' variable.