echo "Which number port would you like to power up or down? 1, 2 or 3?"
read string
case "$string" in
[1]* | [2]* | [3]*) echo "User entered: '$string'" ;;
*) echo "I don't understand '$string'" ;;
esac
有人能阐明为什么这行不通吗? Bash的新手。
答案 0 :(得分:0)
您确定没有“不可破坏的空间”(https://en.wikipedia.org/wiki/Non-breaking_space)吗? 例如在 *)和 echo
之间答案 1 :(得分:-2)
我将其写为:
#!/bin/bash
echo "Which number port would you like to power up or down? 1, 2 or 3?"
read string
case "${string}" in
[123]) echo "User entered: '${string}'" ;;
*) echo "I don't understand '${string}'" ;;
esac
在您的脚本11
或22
中,依此类推也是有效的。