出于某种原因,我没有得到更高的编号模式在这个脚本中工作。外壳脚本与案例模式错误
#!/bin/bash
#
# guess_my_number.bash - my favorite number
echo "Can you guess my favorite number???"
echo -e -n "\n\n\033[32m Pick a number between 0 and 100 > "
read num
case $num in
[0-6]) echo "You're close...but too low" ;;
[8-14]) echo "You're close...but too high" ;;
[15-100]) echo "You're nowhere near my favorite number...sorry, try again" ;;
7) echo "YOU GUESSED MY FAVORITE NUMBER!" ;;
*) echo "You didn't pick a number between 1 and 100!" ;;
esac
如果我改变[8-14]至[8..14]我运行脚本,但是从9-100任何其他数给我的通配符回声响应时,你得到的回声响应,如果我在8型。如果它是[8-14],它也会给我通配符响应。就像我说的[0-6]模式给出了它的回声陈述,那么也是7.
这里我的问题是什么?
[使用案例Numbe的一系列可能的重复在Bash中的正则表达式](http://stackoverflow.com/questions/12614011/using-case-for-range-of-numbers-in-bash) –
[Bash case语句中的正则表达式]的可能重复(http:/ /stackoverflow.com/questions/9631335/regular-expressions-in-a-bash-case-statement) – codeforester
嗯... thanx,但我不知道我是否理解其他问题。 – user7526725