Skip to content

Latest commit

 

History

History
45 lines (39 loc) · 569 Bytes

Shell case 结构.md

File metadata and controls

45 lines (39 loc) · 569 Bytes

「 Shell case 结构 」

💬 格式

case string in
exp1)
    若干个命令行
;;
exp2)
    若干个命令行
;;
...
*)  #用通配符*来处理无匹配项情况
esac

💬 举例

#!/bin/bash
echo "Enter A,B,C"
read letter
case $letter in
A|a)
    echo "you entered A."
;;
B|b)
    echo "you entered B."
;;
C|c)
    echo "you entered C."
;;
*)
    echo "not A,B,C."
esac
- End -