I'm trying to use bash to find if a short string is present in any string "sets". For example,
FRUIT="apple banana kiwi melon"
VEGETABLE="radish lettuce potato"
COLOR="blue red yellow green brown"
MY_CHOICE="kiwi"
MY_CHOICE_GROUP="?"
How can I set MY_CHOICE_GROUP
to FRUIT
?
I tried to use this StackOverflow solution, but it only works with a single string set.
Originally, I was using arrays to store the options in a set, but given the way bash handles iteration over arrays, it seems a string search would be more efficient.
Many thanks!