➜ QA_shell cat case.sh
#!/bin/bash
function func_case()
{
case $1 in
"")
echo "param is null"
;;
"1")
echo "param is number"
;;
"a")
echo "param is word"
;;
"*")
echo "param is signal"
;;
esac
}
func_case $2
➜ QA_shell
➜ QA_shell sh case.sh 3
param is null
➜ QA_shell sh case.sh a
param is null
➜ QA_shell sh case.sh a 1
param is number
[linux-shell]shell的case使用
最新推荐文章于 2024-03-27 01:52:19 发布