質問: "cisco" ] then : # do nothing else echo "phone type must be nortel,cisco or nec" exit fi このタイプのタスクにはより明確な方法がありますか?
回答: @ 0x80ソリューションに基づくバリエーションの提案:# define phone brand list phonebrandlist=" nortel nec cisco" ## separator is space with an extra space in first place # test if user given phone is contained in the list if [[ ${phonebrandlist} =~ (^|[[:space:]])"${userphonebrand}"($|[[:space:]]) ]]; then echo "found it !" fi