I am currently trying to find a string within a variable that outputs something like this:
one,two,three
My code:
echo "please enter one,two or three) read var var1=one,two,threee if [[ "$var" == $var1 ]]; then echo "$var is in the list" else echo "$var is not in the list" fi EDIT2:
I tried this but still not matching. Yo uwere correct about it not matching the exact string from previous answers as it was matching partial.
groups="$(aws iam list-groups --output text | awk '{print tolower($5)}' | sed '$!s/$/,/' | tr -d '\n')" echo "please enter data" read "var" if [ ",${var}," = *",${groups},"* ]; then echo "$var is in the list" else echo "$var is not in the list" fi Trying this its still not matching the exact string as i need it to.