shell脚本解析6----case语句

BASH中的case结构,可以用于进行多项分支。

case "$var" in

condition1)

    ;;

condition2)

    ;;

*)

  default statments;;

esac

例如:

#!/bin/bash

echo "Hit a key, then hit return"

read Keypress

case "$Keypress" in

  [A-Z]) echo "Uppercase letter";;

  [a-z]) echo "Lowercase letter";;

  [0-9]) echo "Digit";;

  * ) echo "Punctuation, whitespace, or other";;

esac

问题:不知道为什么第5句和第6句,谁在前,就一直输出谁,而不论到底输入的是小写还是大写,这是什么原因呢?

 

posted @ 2014-07-09 18:56  liu_ty10  阅读(184)  评论(0编辑  收藏  举报