我想要这样的东西:
time="1m"
case "$time" in
*h*)
*m*)
*s*)
echo "handling several cases for h, m, s tokens" ;;
*)
echo "handling other cases" ;;
esac
对于 POSIX shell 如何实现这一点?
我想要这样的东西:
time="1m"
case "$time" in
*h*)
*m*)
*s*)
echo "handling several cases for h, m, s tokens" ;;
*)
echo "handling other cases" ;;
esac
对于 POSIX shell 如何实现这一点?
case 命令的语法是:
case 的语法也可以通过以下命令在 bash 中打印(它也适用于 POSIX shell):
语法
man bash
:可以通过模式找到
^ *case
。使用示例:
参考文献及相关问题及示例: