标签:bsp 条件判断 linux function ase $1 else 定义 demo
1??if... then:
if [ 条件判断式1 ]; then
语句一
elif [ 条件判断式2 ]; then
语句二
else
语句三
fi
2??case...esac:
case $变量名称 in #关键字case 还有变量前面的$
"第一个变量内容") #每个变量都是被双引号括起来,关键字是小括号)
程序段
;; #每个类型结尾,使用两个分号
"第二个变量内容")
程序段
;;
*)
不包含第一个变量内容和第二个变量内容的其他程序段
;;
esac #最后的case结尾,是反写的case
示例:
#!/bin/bash
case $1 in
"one")
echo "you input number is one"
;;
"two")
echo "you input number is twp"
;;
*)
echo "you input number is other"
;;
esac
结果是:
[---@k4181v ~]$ sh demo.sh one
you input number is one
3??function函数
function fname(){
程序块
}
function的定义,一定要在使用之前
标签:bsp 条件判断 linux function ase $1 else 定义 demo
原文地址:https://www.cnblogs.com/starstarstar/p/11190636.html