Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我输入例如 ./test sa 或 ./test wn 以使我的函数 echo 仍然工作,是否可以通过某种方式实现它?我尝试使用 [ a] 或 [w ],但它似乎不起作用。
until [ -z $1 ] case in "$1" in wa) echo "hi just testing" ;; esac done
首先,案例陈述是错误的——它是
case "$1" in wa) echo ""hi just testing" ;; esac
如果您尝试级联选项,那么您可以使用“或”逻辑即。
case "$1" in wa|sn) echo ""hi just testing" ;; esac
如果您要处理任一字符的拼写错误,则可以使用:
case "$1" in w?|?a) echo ""hi just testing" ;; esac
?手段匹配任何一个字符。
?