I have a command that will output the following (curl -sSL $location | grep -o "title\=\".*\"\ agent" | grep -o "\".*\"" | grep -o "[a-zA-Z0-9].*[a-zA-Z0-9]"
):
Films
TV Series
I need to make an if-statement where a variable needs to match one of those. e.g.
if [[ $option = Films ]] || [[ $option = "TV Series" ]]
then
echo "True"
fi
But the thing is, Films and TV Series can change. The name can be different. And there is a possibility that there are more strings e.g. Films, TV Series, Music, Radio etc. etc.
or movie, serie, radio, music
. I need to get it so that the variable ($option
) is able to match whatever output comes out of the command. It doesn't have to match every one of them, just one is enough e.g.
Output command:
Films
TV Series
Radio
$option=TV Series -> True
$option=Radio -> True
Output command:
Films
$option=Films -> True
$option=radio -> False
Save all genres in an array without space. You can then match your token against the array (or you can also say string with words).
If the output of the command is a list as you show in the question, you can save it in an array, and check the variable against it:
The following worked:
This should also work, though I haven't tested it.