linux shell编程中 case语句

 

001、

[root@PC1 test]# ls
test.sh
[root@PC1 test]# cat test.sh                       ## 测试脚本
#!/bin/bash

read -p "please input an character:" key           ## 给变量key赋值

case $key in                                       ## case进行匹配
        [0-9])
                echo "number!"
                ;;
        [a-z]|[A-Z])
                echo "letter!"
                ;;
        *)
                echo "other!"
                ;;
esac

 

posted @ 2023-02-24 22:52  小鲨鱼2018  阅读(19)  评论(0编辑  收藏  举报