来源:中国IT实验室2010/8/20【考试大:中国教育考试第一门户】模拟考场视频课程字号:T T导读:rhel下shell脚本的语法总结。rhel下shell脚本的语法总结if条件判断控制......
来源:中国IT实验室 2010/8/20 【考试大:中国教育考试第一门户】 模拟考场 视频课程 字号:T T
导读:rhel下shell脚本的语法总结。
rhel下shell脚本的语法总结
if
条件判断控制语句:
if 条件
then 动作
elif 条件
then 动作
else
动作
fi
注释:
?if,当条件为真时,执行then后的动作。elif在if判断为假时才做判断,else在if与elif都为假时执行。
?Example:
# ! /bin/sh
read –p “Enter a password “ pwd_entered
if [ “$pwd_entered” = “password” ]
then
echo Password is correct
else
echo Password is incorrect
fi
case
条件判断控制语句:
case 表达式 in
匹配值 1)
动作;;
匹配值 2)
动作;;
|