在 Shell programming中如何使用 case。
case 語法
case value in
pattern1)
command
...
command
;;
pattern2)
command
...
command
;;
pattern3)
command
...
command
;;
...
esac
範例
1 |
if [ "$#" -ne 1 ] |
進階用法
-
多個情況匹配的時候,類似 or的功能
pattern1 | pattern2 -
一個範圍匹配
[0-9]
近期评论