Hi=("Hi" "Hello" "Hey")行有可能的输入。我尝试在单词之间添加逗号,但这也不起作用。如果输入了hi、hello或hey,我需要它来回显“Hi”。现在只有Hi有效。我想我正在寻找的是一种为一个词制作“同义词”的方法。用一个词代替另一个词的能力。
clear; echo
shopt -s nocasematch
echo; read -p " > " TextInput
Hi=("Hi" "Hello" "Hey")
if [[ "$TextInput" == $Hi ]]; then
clear; echo; echo
echo -e " >> Hi"
echo
else
clear; echo; echo
echo -e " >> Error"
echo
fi
我知道我可以使用
if [[ "$TextInput" == "Hi" ]] || [[ "$TextInput" == "Hello" ]] || [[ "$TextInput" == "Hey" ]]; then
但这将变得太长了。